How to use the react-cosmos/fixture.useValue function in react-cosmos

To help you get started, we’ve selected a few react-cosmos 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 react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / plugins / FixtureSearch / FixtureSearchOverlay.fixture.tsx View on Github external
return () => {
    const [searchText, setSearchText] = useValue('searchText', {
      defaultValue: ''
    });
    return (
       console.log('Close fixture search overlay')}
        onSelect={selectedFixtureId =>
          console.log('Select fixture', selectedFixtureId)
        }
      />
    );
github react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / plugins / FixtureTree / FixtureTree / index.fixture.tsx View on Github external
return () => {
    const [
      selectedFixtureId,
      setSelectedFixtureId
    ] = useValue('selectedFixtureId', { defaultValue: fixtureId });
    const [treeExpansion, setTreeExpansion] = useValue('treeExpansion', {
      defaultValue: initialTreeExpansion
    });
    return (
      
    );
  };
}
github react-cosmos / react-cosmos / example / CounterButton / index.fixture.tsx View on Github external
export default () => {
  const [count, setCount] = useValue('count', { defaultValue: 0 });
  return (
     setCount(prevCount => prevCount + 1)}
    />
  );
};
github react-cosmos / react-cosmos / example / __fixtures__ / Values Playground.tsx View on Github external
export default () => {
  const [string] = useValue('string', { defaultValue: 'How are you doing?' });
  const [number] = useValue('number', { defaultValue: 1989 });
  const [boolean] = useValue('boolean', { defaultValue: true });
  const [object] = useValue('object', {
    defaultValue: { isAdmin: true, name: 'Pat D', age: 44 }
  });
  const [array] = useValue('array', {
    defaultValue: [
      { isAdmin: true, name: 'Pat D', age: 44 },
      { isAdmin: false, name: 'Dan B', age: 39 }
    ]
  });

  return (
github react-cosmos / react-cosmos / example / __fixtures__ / Values Playground.tsx View on Github external
export default () => {
  const [string] = useValue('string', { defaultValue: 'How are you doing?' });
  const [number] = useValue('number', { defaultValue: 1989 });
  const [boolean] = useValue('boolean', { defaultValue: true });
  const [object] = useValue('object', {
    defaultValue: { isAdmin: true, name: 'Pat D', age: 44 }
  });
  const [array] = useValue('array', {
    defaultValue: [
      { isAdmin: true, name: 'Pat D', age: 44 },
      { isAdmin: false, name: 'Dan B', age: 39 }
    ]
  });

  return (
github react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / plugins / ResponsivePreview / ResponsivePreview / Header.fixture.tsx View on Github external
export default () => {
  const [viewport, setViewport] = useValue('viewport', {
    defaultValue: initialViewport
  });
  const [scaled, setScaled] = useValue('scaled', { defaultValue: false });
  const scaleFactor = getViewportScaleFactor(viewport, containerViewport);
  return (
    <header> setScaled(!scaled)}
    /&gt;
  );
};
</header>
github react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / plugins / ValuesPanel / index.fixture.tsx View on Github external
}
            },
            currentValue: {
              type: 'object',
              values: {
                isAdmin: { type: 'primitive', value: true },
                name: { type: 'primitive', value: 'Pat D' },
                age: { type: 'primitive', value: 45 }
              }
            }
          }
        }
      }
    }
  );
  const [treeExpansion, setTreeExpansion] = useValue('treeExpansion', {
    defaultValue: {}
  });

  return (
    
  );
};
github react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / plugins / ValuesPanel / index.fixture.tsx View on Github external
export default () =&gt; {
  const [fixtureState, setFixtureState] = useValue(
    'fixtureState',
    {
      defaultValue: {
        values: {
          string: {
            defaultValue: { type: 'primitive', value: 'hello world' },
            currentValue: { type: 'primitive', value: 'hello world' }
          },
          number: {
            defaultValue: { type: 'primitive', value: 1337 },
            currentValue: { type: 'primitive', value: 1337 }
          },
          boolean: {
            defaultValue: { type: 'primitive', value: false },
            currentValue: { type: 'primitive', value: false }
          },
github react-cosmos / react-cosmos / packages / react-cosmos-playground2 / src / shared / ui / valueInputTree / index.fixture.tsx View on Github external
type: 'unserializable',
            stringifiedValue: '<div>'
          }
        }
      },
      string: {
        type: 'primitive',
        value: 'hello world'
      },
      number: {
        type: 'primitive',
        value: 1337
      }
    }
  });
  const [treeExpansion, setTreeExpansion] = useValue(
    'treeExpansion',
    { defaultValue: { object: true } }
  );
  return (
    
  );
};
</div>
github react-cosmos / react-cosmos / example / __fixtures__ / Values Playground.tsx View on Github external
export default () =&gt; {
  const [string] = useValue('string', { defaultValue: 'How are you doing?' });
  const [number] = useValue('number', { defaultValue: 1989 });
  const [boolean] = useValue('boolean', { defaultValue: true });
  const [object] = useValue('object', {
    defaultValue: { isAdmin: true, name: 'Pat D', age: 44 }
  });
  const [array] = useValue('array', {
    defaultValue: [
      { isAdmin: true, name: 'Pat D', age: 44 },
      { isAdmin: false, name: 'Dan B', age: 39 }
    ]
  });

  return (
    
  );
};

react-cosmos

Sandbox for developing and testing UI components in isolation

MIT
Latest version published 8 days ago

Package Health Score

73 / 100
Full package analysis