How to use the styletron-react.withStyle function in styletron-react

To help you get started, we’ve selected a few styletron-react 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 styletron / styletron / packages / flow-type-tests / inferred-deep-composition.js View on Github external
// $FlowFixMe
; // Missing foo
// $FlowFixMe
; // Wrong foo
// $FlowFixMe
; // Missing bar
// $FlowFixMe
; // Wrong bar
// $FlowFixMe
; // Missing baz
// $FlowFixMe
; // Wrong baz

;

const Qux = withStyle(Baz, (_props: {qux: "qux"}) => ({color: "red"}));

// $FlowFixMe
; // Missing foo
// $FlowFixMe
; // Wrong foo
// $FlowFixMe
; // Missing bar
// $FlowFixMe
; // Wrong bar
// $FlowFixMe
; // Missing baz
// $FlowFixMe
; // Wrong baz
// $FlowFixMe
; // Missing qux
// $FlowFixMe
github styletron / styletron / packages / flow-type-tests / with-wrapper-typed.js View on Github external
),
);

// $FlowFixMe
; // missing foo and bar

// $FlowFixMe
; // missing bar

// $FlowFixMe
; // missing foo

;

const Baz = withStyle(Bar, (props: {foo: "foo", bar: "bar", baz: "baz"}) => ({
  color: props.baz,
}));

// $FlowFixMe
; // Missing foo
// $FlowFixMe
; // Wrong foo
// $FlowFixMe
; // Missing bar
// $FlowFixMe
; // Wrong bar
// $FlowFixMe
; // Missing baz
// $FlowFixMe
; // Wrong baz
github DefinitelyTyped / DefinitelyTyped / types / styletron-react / styletron-react-tests.tsx View on Github external
// withWrapper()
// --------------------------

const PrettyButton = styled('button', { background: 'green' });

const { Consumer } = React.createContext(true);

const WithWrapped = withWrapper(PrettyButton, Styled => props => (
    {value => }
));

;

// Style composition still works as normal;
const StyledWithWrapper = withStyle(WithWrapped, { background: 'red' });

;

// 
// --------------------------

const engineNoop = (arg: any) => (arg ? '' : '');

const engine: StandardEngine = {
    renderStyle: engineNoop,
    renderKeyframes: engineNoop,
    renderFontFace: engineNoop,
};

const App = () => (
github DefinitelyTyped / DefinitelyTyped / types / styletron-react / styletron-react-tests.tsx View on Github external
;

// withStyle()
// --------------------------

// Static Styles
const WithStyledSimple = withStyle(BasicStyled, { color: 'blue' });

;

// Dynamic Styles
interface WithStyledDynamicProps {
    $crushed: boolean;
}

const WithStyledDynamic = withStyle(BasicStyled, (props: WithStyledDynamicProps) => ({
    letterSpacing: props.$crushed ? '-5px' : '0',
}));

;

// withStyleDeep()
// --------------------------

// Static Styles
const WithStyledDeepSimple = withStyleDeep(BasicStyled, { color: 'blue' });

;

// Dynamic Styles
interface WithStyledDeepDynamicProps {
    $crushed: boolean;
github styletron / styletron / packages / flow-type-tests / inferred-deep-composition.js View on Github external
import {styled, withStyle, withWrapper} from "styletron-react";

// Note: explicit generic annotation is here because this is not inferred correctly
const Foo = styled<{foo: "foo"}>("div", (_props: {foo: "foo"}) => ({
  color: "red",
}));

// $FlowFixMe
; // Missing foo

// $FlowFixMe
; // Wrong foo

;

const Bar = withStyle(Foo, (_props: {bar: "bar"}) => ({color: "red"}));

// $FlowFixMe
; // Missing foo
// $FlowFixMe
; // Wrong foo
// $FlowFixMe
; // Missing bar
// $FlowFixMe
; // Wrong bar

;

const Baz = withStyle(Bar, (_props: {baz: "baz"}) => ({color: "red"}));

// $FlowFixMe
; // Missing foo
github uber / baseweb / documentation-site / components / example.js View on Github external
import {withStyle} from 'styletron-react';
import {Button, KIND, SIZE} from 'baseui/button';
import {ButtonGroup} from 'baseui/button-group';
import {Card} from 'baseui/card';
import {Block} from 'baseui/block';
import {StyledLink} from 'baseui/link';

import {version} from '../../package.json';
import Code from './code';
import CodeIcon from './code-icon';
//$FlowFixMe
import {trackEvent} from '../helpers/ga';
import {H3} from './markdown-elements';

import {codesandboxIndexCode} from './const';
const Link = withStyle(StyledLink, {cursor: 'pointer'});

function Source(props: {children: ?React.Node}) {
  if (!props.children || typeof props.children !== 'string') return null;
  return <code>{props.children}</code>;
}

type PropsT = {
  additionalPackages: {[string]: string},
  children: React.Node,
  path: string, // required to fetch the uncompiled source code
  title: ?string,
};

type StateT = {
  sourceSelected: number,
  source: ?string,
github uber / baseweb / documentation-site / examples / menu / virtual-list.js View on Github external
// @flow
import React from 'react';
import {withStyle} from 'styletron-react';
import {StatefulMenu, OptionList, StyledList} from 'baseui/menu';
import List from 'react-virtualized/dist/commonjs/List';
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';

const ITEMS = [...new Array(1500)].map((_, index) =&gt; ({
  label: `item number: ${index + 1}`,
}));

const Container = withStyle(StyledList, {height: '500px'});

const VirtualList = React.forwardRef((props, ref) =&gt; {
  const children = React.Children.toArray(props.children);
  return (
    
      
        {({width}) =&gt; (
           (
github uber / baseweb / src / textarea / examples.js View on Github external
const Button = styled('button', ({$theme}) => {
  return {
    ...$theme.typography.font300,
    display: 'block',
    paddingTop: '10px',
    paddingRight: '12px',
    paddingBottom: '10px',
    paddingLeft: '12px',
    marginTop: '8px',
    width: '100%',
    borderRadius: $theme.sizing.scale100,
    borderWidth: 'none',
  };
});

const TextareaWithStyle = withStyle(StyledTextarea, props => {
  const {
    $disabled,
    $error,
    $isFocused,
    $theme: {colors, sizing},
  } = props;
  return {
    borderColor: $disabled
      ? colors.borderAlt
      : $error
        ? colors.borderError
        : $isFocused
          ? 'darkseagreen'
          : colors.border,
    boxShadow: `0 0 ${sizing.scale100} ${
      $disabled
github uber / baseweb / src / radio / examples.js View on Github external
[examples.STYLES_OVERRIDES]: () =&gt; {
    const overrides = {
      RadioMark: {
        style: {borderColor: 'red'},
      },
      Label: withStyle(StyledLabel, () =&gt; {
        return {
          color: 'orange',
          fontSize: '25px',
        };
      }),
    };
    return (
      
        First
        Second
        Third
      
    );
  },
  [examples.WITH_ERROR]: () =&gt; {
github uber / baseweb / src / checkbox / examples.js View on Github external
[examples.STYLES_OVERRIDES]: () =&gt; {
    return (
       {
            return {
              border: `1px solid green`,
              padding: '10px',
            };
          }),
          Label: withStyle(StyledLabel, () =&gt; {
            return {
              color: 'orange',
              fontSize: '25px',
            };
          }),
          Checkmark: withStyle(StyledCheckmark, props =&gt; {
            const {checked} = props;
            return checked
              ? {borderColor: 'pink'}
              : {

styletron-react

React bindings for Styletron

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis

Similar packages