@sinchsmb/ui-kit
Version:
UI kit for SinchSMB frontend
20 lines (17 loc) • 490 B
text/typescript
import get from 'lodash/get';
import { ColorToken, ColorTokenRef, PropsWithTheme } from './types';
/**
* Returns color that can be used inside styled-component.
*
* ```tsx
* import styled from 'styled-components/macro';
* import { color } from '../theme';
*
* const StyledDiv = styled.div`
* background-color: ${color("gray/50")};
* `;
* ```
*/
export function color(name: ColorTokenRef) {
return (props: PropsWithTheme): ColorToken => get(props.theme, name.split('/'));
}