How to use the @xstyled/system.th function in @xstyled/system

To help you get started, we’ve selected a few @xstyled/system examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / xstyled__system / xstyled__system-tests.tsx View on Github external
const InnerSystemComponentBox = createSystemComponent(React, 'div', shadows);

const SystemComponentBox = styled(InnerSystemComponentBox)`
    ${shadows}
`;

const systemComponentBoxTest = () => (
    <div>
        
    </div>
);

// TH

th('colors.primary900')({});

th.color(2)({});
th.color('primary')({});

th.px(2)({});
th.px('2rpx')({});

th.percent(0.3)({});
th.percent('20em')({});

th.radius(2)({});
th.radius('sm')({});

th.transition(2)({});
th.transition('fade')({});
github RetailMeNot / anchor / src / Skeleton / Skeleton.component.tsx View on Github external
export const Skeleton = ({
    className,
    children,
    textLength,
    loading = true,
    colorStart = th('skeleton.colorStart'),
    colorEnd = th('skeleton.colorEnd'),
    ...props
}: SkeletonProps): React.ReactElement | any =&gt; {
    if (!loading) {
        return typeof children === 'undefined' ? null : children;
    }

    // This is the conversion from block width to the average width of
    // a normal distribution of letters. We came up with it by eyeballing it
    // for the Avenir Next font. We should make it configurable via theme/prop
    // or make further calculations to improve it.
    const blockToAverageCharQuotient = 2.15;

    // This is the unicode block character that put together looks like one
    // long bar. There are shorter and taller characters that could be used
    // or a fatter or thinner bar. Therefore the bar thickness chould be made
    // a prop in the future, mapping to different block characters.
github RetailMeNot / anchor / src / theme / GlobalStyles / Globals.styles.ts View on Github external
// VENDOR
import { createGlobalStyle } from '@xstyled/styled-components';
import { th } from '@xstyled/system';

export const GlobalCSS = createGlobalStyle`
  html,
  body {
    font-family: base;
    color: text.body;
    font-size: ${th('typography.fontSize')};
    letter-spacing: 0;
    line-height: 1.357142857rem;
  }
`;
github RetailMeNot / anchor / src / Skeleton / Skeleton.component.tsx View on Github external
export const Skeleton = ({
    className,
    children,
    textLength,
    loading = true,
    colorStart = th('skeleton.colorStart'),
    colorEnd = th('skeleton.colorEnd'),
    ...props
}: SkeletonProps): React.ReactElement | any =&gt; {
    if (!loading) {
        return typeof children === 'undefined' ? null : children;
    }

    // This is the conversion from block width to the average width of
    // a normal distribution of letters. We came up with it by eyeballing it
    // for the Avenir Next font. We should make it configurable via theme/prop
    // or make further calculations to improve it.
    const blockToAverageCharQuotient = 2.15;

    // This is the unicode block character that put together looks like one
    // long bar. There are shorter and taller characters that could be used
    // or a fatter or thinner bar. Therefore the bar thickness chould be made
github RetailMeNot / anchor / src / Typography / Typography.component.tsx View on Github external
${props =>
        css({
            fontFamily: 'base',
            fontSize: th('typography.fontSize'),
            lineHeight: th('typography.lineHeight'),
            fontWeight: th('typography.fontWeight'),
            textAlign: 'inherit',
            color: 'inherit',
            ...variant({
                key: 'typography.tag',
                default: 'none',
                prop: 'tag',
            })(props),
            ...variant({
                key: 'typography.scale',
                default: 'none',
                prop: 'scale',
            })(props),
        })}
github RetailMeNot / anchor / src / Typography / Typography.component.tsx View on Github external
${props =>
        css({
            fontFamily: 'base',
            fontSize: th('typography.fontSize'),
            lineHeight: th('typography.lineHeight'),
            fontWeight: th('typography.fontWeight'),
            textAlign: 'inherit',
            color: 'inherit',
            ...variant({
                key: 'typography.tag',
                default: 'none',
                prop: 'tag',
            })(props),
            ...variant({
                key: 'typography.scale',
                default: 'none',
                prop: 'scale',
            })(props),
        })}
github smooth-code / smooth-ui / packages / shared / core / Alert.js View on Github external
Alert: p => {
          const baseColor =
            p.variant === null ? null : th.color(p.variant || 'primary')(p)
          const textColorLevel = th('colorLevels.Alert.color')(p)
          const backgroundColorLevel = th('colorLevels.Alert.backgroundColor')(
            p,
          )
          const borderColorLevel = th('colorLevels.Alert.borderColor')(p)
          const color = colorLevel(baseColor, textColorLevel)(p)
          const backgroundColor = colorLevel(baseColor, backgroundColorLevel)(p)
          const borderColor = colorLevel(baseColor, borderColorLevel)(p)
          const hrColor = darken(0.05, color)
          return css`
            font-family: ${th.font('base')(p)};
            position: relative;
            padding: 12rpx 20rpx;
            margin-bottom: 16rpx;
            border: 1rpx;
            border-color: transparent;
            border-radius: ${th.radius('base')(p)};
github smooth-code / smooth-ui / packages / shared / core / Alert.js View on Github external
Alert: p => {
          const baseColor =
            p.variant === null ? null : th.color(p.variant || 'primary')(p)
          const textColorLevel = th('colorLevels.Alert.color')(p)
          const backgroundColorLevel = th('colorLevels.Alert.backgroundColor')(
            p,
          )
          const borderColorLevel = th('colorLevels.Alert.borderColor')(p)
          const color = colorLevel(baseColor, textColorLevel)(p)
          const backgroundColor = colorLevel(baseColor, backgroundColorLevel)(p)
          const borderColor = colorLevel(baseColor, borderColorLevel)(p)
          const hrColor = darken(0.05, color)
          return css`
            font-family: ${th.font('base')(p)};
            position: relative;
            padding: 12rpx 20rpx;
            margin-bottom: 16rpx;
            border: 1rpx;
            border-color: transparent;
            border-radius: ${th.radius('base')(p)};
            color: ${color};
            background-color: ${backgroundColor};
            border-color: ${borderColor};
github smooth-code / smooth-ui / packages / shared / core / Alert.js View on Github external
Alert: p => {
          const baseColor =
            p.variant === null ? null : th.color(p.variant || 'primary')(p)
          const textColorLevel = th('colorLevels.Alert.color')(p)
          const backgroundColorLevel = th('colorLevels.Alert.backgroundColor')(
            p,
          )
          const borderColorLevel = th('colorLevels.Alert.borderColor')(p)
          const color = colorLevel(baseColor, textColorLevel)(p)
          const backgroundColor = colorLevel(baseColor, backgroundColorLevel)(p)
          const borderColor = colorLevel(baseColor, borderColorLevel)(p)
          const hrColor = darken(0.05, color)
          return css`
            font-family: ${th.font('base')(p)};
            position: relative;
            padding: 12rpx 20rpx;
            margin-bottom: 16rpx;
            border: 1rpx;
            border-color: transparent;
            border-radius: ${th.radius('base')(p)};
            color: ${color};
github RetailMeNot / anchor / src / Typography / Typography.component.tsx View on Github external
${props =>
        css({
            fontFamily: 'base',
            fontSize: th('typography.fontSize'),
            lineHeight: th('typography.lineHeight'),
            fontWeight: th('typography.fontWeight'),
            textAlign: 'inherit',
            color: 'inherit',
            ...variant({
                key: 'typography.tag',
                default: 'none',
                prop: 'tag',
            })(props),
            ...variant({
                key: 'typography.scale',
                default: 'none',
                prop: 'scale',
            })(props),
        })}