How to use WithLabel method in storybook-root

Best JavaScript code snippet using storybook-root

TextInputExample.ios.js

Source:TextInputExample.ios.js Github

copy

Full Screen

1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @format8 * @flow9 */10'use strict';11const React = require('react');12const {13 Button,14 InputAccessoryView,15 Text,16 TextInput,17 View,18 StyleSheet,19 Slider,20 Switch,21 Alert,22} = require('react-native');23import type {KeyboardType} from 'react-native/Libraries/Components/TextInput/TextInput';24const TextInputSharedExamples = require('./TextInputSharedExamples.js');25import type {RNTesterExampleModuleItem} from '../../types/RNTesterTypes';26class WithLabel extends React.Component<$FlowFixMeProps> {27 render() {28 return (29 <View style={styles.labelContainer}>30 <View style={styles.label}>31 <Text>{this.props.label}</Text>32 </View>33 {this.props.children}34 </View>35 );36 }37}38class TextInputAccessoryViewChangeTextExample extends React.Component<39 {...},40 *,41> {42 constructor(props) {43 super(props);44 this.state = {text: 'Placeholder Text'};45 }46 render() {47 const inputAccessoryViewID = 'inputAccessoryView1';48 return (49 <View>50 <Text>Set InputAccessoryView with ID & reset text:</Text>51 <TextInput52 style={styles.default}53 inputAccessoryViewID={inputAccessoryViewID}54 onChangeText={text => this.setState({text})}55 value={this.state.text}56 />57 <InputAccessoryView nativeID={inputAccessoryViewID}>58 <View style={{backgroundColor: 'white'}}>59 <Button60 onPress={() => this.setState({text: 'Placeholder Text'})}61 title="Reset Text"62 />63 </View>64 </InputAccessoryView>65 </View>66 );67 }68}69class TextInputAccessoryViewChangeKeyboardExample extends React.Component<70 {...},71 *,72> {73 constructor(props) {74 super(props);75 this.state = {text: '', keyboardType: 'default'};76 }77 _switchKeyboard = () => {78 this.setState({79 keyboardType:80 this.state.keyboardType === 'default' ? 'number-pad' : 'default',81 });82 };83 render() {84 const inputAccessoryViewID = 'inputAccessoryView2';85 return (86 <View>87 <Text>Set InputAccessoryView with ID & switch keyboard:</Text>88 <TextInput89 style={styles.default}90 inputAccessoryViewID={inputAccessoryViewID}91 onChangeText={text => this.setState({text})}92 value={this.state.text}93 keyboardType={this.state.keyboardType}94 returnKeyType="done"95 />96 <InputAccessoryView nativeID={inputAccessoryViewID}>97 <View style={{backgroundColor: 'white'}}>98 <Button onPress={this._switchKeyboard} title="Switch Keyboard" />99 </View>100 </InputAccessoryView>101 </View>102 );103 }104}105class TextInputAccessoryViewDefaultDoneButtonExample extends React.Component<106 $ReadOnly<{|107 keyboardType: KeyboardType,108 |}>,109 *,110> {111 constructor(props) {112 super(props);113 this.state = {text: ''};114 }115 render() {116 return (117 <TextInput118 style={styles.default}119 onChangeText={text => this.setState({text})}120 value={this.state.text}121 keyboardType={this.props.keyboardType}122 returnKeyType="done"123 />124 );125 }126}127class RewriteExampleKana extends React.Component<$FlowFixMeProps, any> {128 constructor(props) {129 super(props);130 this.state = {text: ''};131 }132 render() {133 return (134 <View style={styles.rewriteContainer}>135 <TextInput136 multiline={false}137 onChangeText={text => {138 this.setState({text: text.replace(/ひ/g, '日')});139 }}140 style={styles.default}141 value={this.state.text}142 />143 </View>144 );145 }146}147class SecureEntryExample extends React.Component<$FlowFixMeProps, any> {148 constructor(props) {149 super(props);150 this.state = {151 text: '',152 password: '',153 isSecureTextEntry: true,154 };155 }156 render() {157 return (158 <View>159 <TextInput160 secureTextEntry={true}161 style={styles.default}162 defaultValue="abc"163 onChangeText={text => this.setState({text})}164 value={this.state.text}165 />166 <Text>Current text is: {this.state.text}</Text>167 <View168 style={{169 flex: 1,170 flexDirection: 'row',171 }}>172 <TextInput173 style={styles.default}174 defaultValue="cde"175 onChangeText={text => this.setState({password: text})}176 secureTextEntry={this.state.isSecureTextEntry}177 value={this.state.password}178 />179 <Switch180 onValueChange={value => {181 this.setState({isSecureTextEntry: value});182 }}183 style={{marginLeft: 4}}184 value={this.state.isSecureTextEntry}185 />186 </View>187 </View>188 );189 }190}191class AutogrowingTextInputExample extends React.Component<192 $FlowFixMeProps,193 $FlowFixMeState,194> {195 constructor(props) {196 super(props);197 this.state = {198 width: 100,199 multiline: true,200 text: '',201 contentSize: {202 width: 0,203 height: 0,204 },205 };206 }207 UNSAFE_componentWillReceiveProps(props) {208 this.setState({209 multiline: props.multiline,210 });211 }212 render() {213 const {style, multiline, ...props} = this.props;214 return (215 <View>216 <Text>Width:</Text>217 <Slider218 value={100}219 minimumValue={0}220 maximumValue={100}221 step={10}222 onValueChange={value => this.setState({width: value})}223 />224 <Text>Multiline:</Text>225 <Switch226 value={this.state.multiline}227 onValueChange={value => this.setState({multiline: value})}228 />229 <Text>TextInput:</Text>230 <TextInput231 value="prop"232 multiline={this.state.multiline}233 style={[style, {width: this.state.width + '%'}]}234 onChangeText={value => this.setState({text: value})}235 onContentSizeChange={event =>236 this.setState({contentSize: event.nativeEvent.contentSize})237 }238 {...props}239 />240 <Text>Plain text value representation:</Text>241 <Text>{this.state.text}</Text>242 <Text>Content Size: {JSON.stringify(this.state.contentSize)}</Text>243 </View>244 );245 }246}247const styles = StyleSheet.create({248 default: {249 borderWidth: StyleSheet.hairlineWidth,250 borderColor: '#0f0f0f',251 flex: 1,252 fontSize: 13,253 padding: 4,254 },255 multiline: {256 borderWidth: StyleSheet.hairlineWidth,257 borderColor: '#0f0f0f',258 flex: 1,259 fontSize: 13,260 height: 50,261 padding: 4,262 marginBottom: 4,263 },264 multilinePlaceholderStyles: {265 letterSpacing: 10,266 lineHeight: 20,267 textAlign: 'center',268 },269 multilineExpandable: {270 height: 'auto',271 maxHeight: 100,272 },273 multilineWithFontStyles: {274 color: 'blue',275 fontWeight: 'bold',276 fontSize: 18,277 fontFamily: 'Cochin',278 height: 60,279 },280 singlelinePlaceholderStyles: {281 letterSpacing: 10,282 textAlign: 'center',283 },284 labelContainer: {285 flexDirection: 'row',286 marginVertical: 2,287 flex: 1,288 },289 label: {290 width: 115,291 alignItems: 'flex-end',292 marginRight: 10,293 paddingTop: 2,294 },295 rewriteContainer: {296 flexDirection: 'row',297 alignItems: 'center',298 },299 remainder: {300 textAlign: 'right',301 width: 24,302 },303});304exports.displayName = (undefined: ?string);305exports.title = 'TextInput';306exports.documentationURL = 'https://reactnative.dev/docs/textinput';307exports.category = 'Basic';308exports.description = 'Single and multi-line text inputs.';309exports.examples = ([310 ...TextInputSharedExamples,311 {312 title: 'Live Re-Write (ひ -> 日)',313 render: function(): React.Node {314 return <RewriteExampleKana />;315 },316 },317 {318 title: 'Keyboard Input Accessory View',319 render: function(): React.Node {320 return (321 <View>322 <TextInputAccessoryViewChangeTextExample />323 <TextInputAccessoryViewChangeKeyboardExample />324 </View>325 );326 },327 },328 {329 title: "Default Input Accessory View with returnKeyType = 'done'",330 render: function(): React.Node {331 const keyboardTypesWithDoneButton = [332 'number-pad',333 'phone-pad',334 'decimal-pad',335 'ascii-capable-number-pad',336 ];337 const examples = keyboardTypesWithDoneButton.map(type => {338 return (339 <WithLabel key={'keyboardType: ' + type} label={type}>340 <TextInputAccessoryViewDefaultDoneButtonExample341 key={type}342 keyboardType={type}343 />344 </WithLabel>345 );346 });347 return <View>{examples}</View>;348 },349 },350 {351 title: 'Nested content and `value` property',352 render: function(): React.Node {353 return (354 <View>355 <WithLabel label="singleline">356 <TextInput style={styles.default} value="(value property)">357 (first raw text node)358 <Text style={{color: 'red'}}>(internal raw text node)</Text>359 (last raw text node)360 </TextInput>361 </WithLabel>362 <WithLabel label="multiline">363 <TextInput364 style={styles.default}365 multiline={true}366 value="(value property)">367 (first raw text node)368 <Text style={{color: 'red'}}>(internal raw text node)</Text>369 (last raw text node)370 </TextInput>371 </WithLabel>372 </View>373 );374 },375 },376 {377 title: 'Keyboard appearance',378 render: function(): React.Node {379 const keyboardAppearance = ['default', 'light', 'dark'];380 const examples = keyboardAppearance.map(type => {381 return (382 <WithLabel key={type} label={type}>383 <TextInput keyboardAppearance={type} style={styles.default} />384 </WithLabel>385 );386 });387 return <View>{examples}</View>;388 },389 },390 {391 title: 'Return key types',392 render: function(): React.Node {393 const returnKeyTypes = [394 'default',395 'go',396 'google',397 'join',398 'next',399 'route',400 'search',401 'send',402 'yahoo',403 'done',404 'emergency-call',405 ];406 const examples = returnKeyTypes.map(type => {407 return (408 <WithLabel key={type} label={type}>409 <TextInput returnKeyType={type} style={styles.default} />410 </WithLabel>411 );412 });413 return <View>{examples}</View>;414 },415 },416 {417 title: 'Enable return key automatically',418 render: function(): React.Node {419 return (420 <View>421 <WithLabel label="true">422 <TextInput423 enablesReturnKeyAutomatically={true}424 style={styles.default}425 />426 </WithLabel>427 </View>428 );429 },430 },431 {432 title: 'Secure text entry',433 render: function(): React.Node {434 return <SecureEntryExample />;435 },436 },437 {438 title: 'Colored input text',439 render: function(): React.Node {440 return (441 <View>442 <TextInput443 style={[styles.default, {color: 'blue'}]}444 defaultValue="Blue"445 />446 <TextInput447 style={[styles.default, {color: 'green'}]}448 defaultValue="Green"449 />450 </View>451 );452 },453 },454 {455 title: 'Colored highlight/cursor for text input',456 render: function(): React.Node {457 return (458 <View>459 <TextInput460 style={styles.default}461 selectionColor={'green'}462 defaultValue="Highlight me"463 />464 <TextInput465 style={styles.default}466 selectionColor={'rgba(86, 76, 205, 1)'}467 defaultValue="Highlight me"468 />469 </View>470 );471 },472 },473 {474 title: 'Clear button mode',475 render: function(): React.Node {476 const clearButtonModes = [477 'never',478 'while-editing',479 'unless-editing',480 'always',481 ];482 const examples = clearButtonModes.map(mode => {483 return (484 <WithLabel key={mode} label={mode}>485 <TextInput486 style={styles.default}487 clearButtonMode={mode}488 defaultValue={mode}489 />490 </WithLabel>491 );492 });493 return <View>{examples}</View>;494 },495 },496 {497 title: 'Clear and select',498 render: function(): React.Node {499 return (500 <View>501 <WithLabel label="clearTextOnFocus">502 <TextInput503 placeholder="text is cleared on focus"504 defaultValue="text is cleared on focus"505 style={styles.default}506 clearTextOnFocus={true}507 />508 </WithLabel>509 <WithLabel label="selectTextOnFocus">510 <TextInput511 placeholder="text is selected on focus"512 defaultValue="text is selected on focus"513 style={styles.default}514 selectTextOnFocus={true}515 />516 </WithLabel>517 <WithLabel label="clearTextOnFocus (multiline)">518 <TextInput519 placeholder="text is cleared on focus"520 defaultValue="text is cleared on focus"521 style={styles.default}522 clearTextOnFocus={true}523 multiline={true}524 />525 </WithLabel>526 <WithLabel label="selectTextOnFocus (multiline)">527 <TextInput528 placeholder="text is selected on focus"529 defaultValue="text is selected on focus"530 style={styles.default}531 selectTextOnFocus={true}532 multiline={true}533 />534 </WithLabel>535 </View>536 );537 },538 },539 {540 title: 'Multiline blur on submit',541 render: function(): React.Node {542 return (543 <View>544 <TextInput545 style={styles.multiline}546 placeholder="blurOnSubmit = true"547 returnKeyType="next"548 blurOnSubmit={true}549 multiline={true}550 onSubmitEditing={event =>551 Alert.alert('Alert', event.nativeEvent.text)552 }553 />554 </View>555 );556 },557 },558 {559 title: 'Multiline',560 render: function(): React.Node {561 return (562 <View>563 <TextInput564 placeholder="multiline text input"565 multiline={true}566 style={styles.multiline}567 />568 <TextInput569 placeholder="multiline text input with font styles and placeholder"570 multiline={true}571 clearTextOnFocus={true}572 autoCorrect={true}573 autoCapitalize="words"574 placeholderTextColor="red"575 keyboardType="url"576 style={[styles.multiline, styles.multilineWithFontStyles]}577 />578 <TextInput579 placeholder="multiline text input with max length"580 maxLength={5}581 multiline={true}582 style={styles.multiline}583 />584 <TextInput585 placeholder="uneditable multiline text input"586 editable={false}587 multiline={true}588 style={styles.multiline}589 />590 <TextInput591 defaultValue="uneditable multiline text input with phone number detection: 88888888."592 editable={false}593 multiline={true}594 style={styles.multiline}595 dataDetectorTypes="phoneNumber"596 />597 </View>598 );599 },600 },601 {602 title: 'TextInput Intrinsic Size',603 render: function(): React.Node {604 return (605 <View>606 <Text>Singleline TextInput</Text>607 <View style={{height: 80}}>608 <TextInput609 style={{610 position: 'absolute',611 fontSize: 16,612 backgroundColor: '#eeeeee',613 borderColor: '#666666',614 borderWidth: 5,615 borderTopWidth: 20,616 borderRadius: 10,617 borderBottomRightRadius: 20,618 padding: 10,619 paddingTop: 20,620 }}621 testID="singleline_textinput"622 placeholder="Placeholder defines intrinsic size"623 />624 </View>625 <Text>Multiline TextInput</Text>626 <View style={{height: 130}}>627 <TextInput628 style={{629 position: 'absolute',630 fontSize: 16,631 backgroundColor: '#eeeeee',632 borderColor: '#666666',633 borderWidth: 5,634 borderTopWidth: 20,635 borderRadius: 10,636 borderBottomRightRadius: 20,637 padding: 10,638 paddingTop: 20,639 maxHeight: 100,640 }}641 testID="multiline_textinput"642 multiline={true}643 placeholder="Placeholder defines intrinsic size"644 />645 </View>646 <View>647 <TextInput648 style={{649 fontSize: 16,650 backgroundColor: '#eeeeee',651 borderColor: '#666666',652 borderWidth: 5,653 borderTopWidth: 20,654 borderRadius: 10,655 borderBottomRightRadius: 20,656 padding: 10,657 paddingTop: 20,658 }}659 testID="multiline_textinput_with_flex"660 multiline={true}661 placeholder="Placeholder defines intrinsic size"662 />663 </View>664 </View>665 );666 },667 },668 {669 title: 'Auto-expanding',670 render: function(): React.Node {671 return (672 <View>673 <TextInput674 placeholder="height increases with content"675 defaultValue="React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native."676 multiline={true}677 enablesReturnKeyAutomatically={true}678 returnKeyType="go"679 style={[styles.multiline, styles.multilineExpandable]}680 />681 </View>682 );683 },684 },685 {686 title: 'Auto-expanding',687 render: function(): React.Node {688 return (689 <View>690 <AutogrowingTextInputExample691 enablesReturnKeyAutomatically={true}692 returnKeyType="done"693 multiline={true}694 style={{695 maxHeight: 400,696 minHeight: 20,697 paddingTop: 0,698 backgroundColor: '#eeeeee',699 color: 'blue',700 }}>701 <Text style={{fontSize: 30, color: 'green'}}>huge</Text>702 generic generic generic703 <Text style={{fontSize: 6, color: 'red'}}>704 small small small small small small705 </Text>706 <Text>regular regular</Text>707 <Text style={{fontSize: 30, color: 'green'}}>708 huge huge huge huge huge709 </Text>710 generic generic generic711 </AutogrowingTextInputExample>712 </View>713 );714 },715 },716 {717 title: 'TextInput maxLength',718 render: function(): React.Node {719 return (720 <View>721 <WithLabel label="maxLength: 5">722 <TextInput maxLength={5} style={styles.default} />723 </WithLabel>724 <WithLabel label="maxLength: 5 with placeholder">725 <TextInput726 maxLength={5}727 placeholder="ZIP code entry"728 style={styles.default}729 />730 </WithLabel>731 <WithLabel label="maxLength: 5 with default value already set">732 <TextInput733 maxLength={5}734 defaultValue="94025"735 style={styles.default}736 />737 </WithLabel>738 <WithLabel label="maxLength: 5 with very long default value already set">739 <TextInput740 maxLength={5}741 defaultValue="9402512345"742 style={styles.default}743 />744 </WithLabel>745 </View>746 );747 },748 },749 {750 title: 'Text Content Type',751 render: function(): React.Node {752 return (753 <View>754 <WithLabel label="emailAddress">755 <TextInput textContentType="emailAddress" style={styles.default} />756 </WithLabel>757 <WithLabel label="name">758 <TextInput textContentType="name" style={styles.default} />759 </WithLabel>760 </View>761 );762 },763 },764 {765 title: 'TextInput Placeholder Styles',766 render: function(): React.Node {767 return (768 <View>769 <WithLabel label="letterSpacing: 10 lineHeight: 20 textAlign: 'center'">770 <TextInput771 placeholder="multiline text input"772 multiline={true}773 style={[styles.multiline, styles.multilinePlaceholderStyles]}774 />775 </WithLabel>776 <WithLabel label="letterSpacing: 10 textAlign: 'center'">777 <TextInput778 placeholder="singleline"779 style={[styles.default, styles.singlelinePlaceholderStyles]}780 />781 </WithLabel>782 </View>783 );784 },785 },786 {787 title: 'showSoftInputOnFocus',788 render: function(): React.Node {789 return (790 <View>791 <WithLabel label="showSoftInputOnFocus: false">792 <TextInput showSoftInputOnFocus={false} style={[styles.default]} />793 </WithLabel>794 </View>795 );796 },797 },...

Full Screen

Full Screen

PokemonTypes.js

Source:PokemonTypes.js Github

copy

Full Screen

1import PokemonType from '../models/PokemonType';2export default Object.freeze({3 NORMAL: PokemonType.builder()4 .withColor('#9099a1')5 .withLabel('Normal')6 .withIcon('https://cdn2.bulbagarden.net/upload/9/95/Normal_icon_SwSh.png')7 .build(),8 FIGHTING: PokemonType.builder()9 .withColor('#ce4069')10 .withLabel('Fighting')11 .withIcon('https://cdn2.bulbagarden.net/upload/3/3b/Fighting_icon_SwSh.png')12 .build(),13 FLYING: PokemonType.builder()14 .withColor('#8fa8dd')15 .withLabel('Flying')16 .withIcon('https://cdn2.bulbagarden.net/upload/b/b5/Flying_icon_SwSh.png')17 .build(),18 POISON: PokemonType.builder()19 .withColor('#ab6ac8')20 .withLabel('Poison')21 .withIcon('https://cdn2.bulbagarden.net/upload/8/8d/Poison_icon_SwSh.png')22 .build(),23 GROUND: PokemonType.builder()24 .withColor('#d97746')25 .withLabel('Ground')26 .withIcon('https://cdn2.bulbagarden.net/upload/2/27/Ground_icon_SwSh.png')27 .build(),28 ROCK: PokemonType.builder()29 .withColor('#c7b78b')30 .withLabel('Rock')31 .withIcon('https://cdn2.bulbagarden.net/upload/1/11/Rock_icon_SwSh.png')32 .build(),33 BUG: PokemonType.builder()34 .withColor('#90c12c')35 .withLabel('Bug')36 .withIcon('https://cdn2.bulbagarden.net/upload/9/9c/Bug_icon_SwSh.png')37 .build(),38 GHOST: PokemonType.builder()39 .withColor('#5269ac')40 .withLabel('Ghost')41 .withIcon('https://cdn2.bulbagarden.net/upload/0/01/Ghost_icon_SwSh.png')42 .build(),43 STEEL: PokemonType.builder()44 .withColor('#5a8ea1')45 .withLabel('Steel')46 .withIcon('https://cdn2.bulbagarden.net/upload/0/09/Steel_icon_SwSh.png')47 .build(),48 FIRE: PokemonType.builder()49 .withColor('#ff9c54')50 .withLabel('Fire')51 .withIcon('https://cdn2.bulbagarden.net/upload/a/ab/Fire_icon_SwSh.png')52 .build(),53 WATER: PokemonType.builder()54 .withColor('#4d90d5')55 .withLabel('Water')56 .withIcon('https://cdn2.bulbagarden.net/upload/8/80/Water_icon_SwSh.png')57 .build(),58 GRASS: PokemonType.builder()59 .withColor('#63bb5b')60 .withLabel('Grass')61 .withIcon('https://cdn2.bulbagarden.net/upload/a/a8/Grass_icon_SwSh.png')62 .build(),63 ELECTRIC: PokemonType.builder()64 .withColor('#f3d23b')65 .withLabel('Electric')66 .withIcon('https://cdn2.bulbagarden.net/upload/7/7b/Electric_icon_SwSh.png')67 .build(),68 PSYCHIC: PokemonType.builder()69 .withColor('#f97176')70 .withLabel('Psychic')71 .withIcon('https://cdn2.bulbagarden.net/upload/7/73/Psychic_icon_SwSh.png')72 .build(),73 ICE: PokemonType.builder()74 .withColor('#74cec0')75 .withLabel('Ice')76 .withIcon('https://cdn2.bulbagarden.net/upload/1/15/Ice_icon_SwSh.png')77 .build(),78 DRAGON: PokemonType.builder()79 .withColor('#0a6dc4')80 .withLabel('Dragon')81 .withIcon('https://cdn2.bulbagarden.net/upload/7/70/Dragon_icon_SwSh.png')82 .build(),83 DARK: PokemonType.builder()84 .withColor('#5a5366')85 .withLabel('Dark')86 .withIcon('https://cdn2.bulbagarden.net/upload/d/d5/Dark_icon_SwSh.png')87 .build(),88 FAIRY: PokemonType.builder()89 .withColor('#ec8fe6')90 .withLabel('Fairy')91 .withIcon('https://cdn2.bulbagarden.net/upload/c/c6/Fairy_icon_SwSh.png')92 .build(),93 '???': PokemonType.builder()94 .withColor('#68a090')95 .withLabel('???')96 .withIcon('null')97 .build(),...

Full Screen

Full Screen

icons.jsx

Source:icons.jsx Github

copy

Full Screen

1import React from 'react';2import PropTypes from 'prop-types';3import styled from 'styled-components';4import { prop } from '../theme';5import SortArrowUp from '../images/sort-arrow-up.svg';6import SortArrowDown from '../images/sort-arrow-down.svg';7import Github from '../images/github.svg';8import Google from '../images/google.svg';9import Plus from '../images/plus-icon.svg';10import Close from '../images/close.svg';11import Exit from '../images/exit.svg';12import DropdownArrow from '../images/down-filled-triangle.svg';13import Preferences from '../images/preferences.svg';14import Play from '../images/triangle-arrow-right.svg';15import More from '../images/more.svg';16import Code from '../images/code.svg';17import Save from '../images/save.svg';18import Terminal from '../images/terminal.svg';19import Folder from '../images/folder-padded.svg';20import CircleTerminal from '../images/circle-terminal.svg';21import CircleFolder from '../images/circle-folder.svg';22import CircleInfo from '../images/circle-info.svg';23// HOC that adds the right web accessibility props24// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html25// could also give these a default size, color, etc. based on the theme26// Need to add size to these - like small icon, medium icon, large icon. etc.27function withLabel(SvgComponent) {28 const Icon = (props) => {29 const StyledIcon = styled(SvgComponent)`30 &&& {31 color: ${prop('Icon.default')};32 & g,33 & path,34 & polygon {35 opacity: 1;36 fill: ${prop('Icon.default')};37 }38 &:hover {39 color: ${prop('Icon.hover')};40 & g,41 & path,42 & polygon {43 opacity: 1;44 fill: ${prop('Icon.hover')};45 }46 }47 }48 `;49 const { 'aria-label': ariaLabel } = props;50 if (ariaLabel) {51 return (52 <StyledIcon53 {...props}54 aria-label={ariaLabel}55 role="img"56 focusable="false"57 />58 );59 }60 return <StyledIcon {...props} aria-hidden focusable="false" />;61 };62 Icon.propTypes = {63 'aria-label': PropTypes.string64 };65 Icon.defaultProps = {66 'aria-label': null67 };68 return Icon;69}70export const SortArrowUpIcon = withLabel(SortArrowUp);71export const SortArrowDownIcon = withLabel(SortArrowDown);72export const GithubIcon = withLabel(Github);73export const GoogleIcon = withLabel(Google);74export const PlusIcon = withLabel(Plus);75export const CloseIcon = withLabel(Close);76export const ExitIcon = withLabel(Exit);77export const DropdownArrowIcon = withLabel(DropdownArrow);78export const PreferencesIcon = withLabel(Preferences);79export const PlayIcon = withLabel(Play);80export const MoreIcon = withLabel(More);81export const TerminalIcon = withLabel(Terminal);82export const CodeIcon = withLabel(Code);83export const SaveIcon = withLabel(Save);84export const FolderIcon = withLabel(Folder);85export const CircleTerminalIcon = withLabel(CircleTerminal);86export const CircleFolderIcon = withLabel(CircleFolder);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { WithLabel } from 'storybook-root-decorator';4import { withInfo } from '@storybook/addon-info';5storiesOf('WithLabel', module)6 .addDecorator(7 withInfo({8 styles: {9 infoBody: {10 },11 },12 }),13 .add('default', () => <WithLabel>Default</WithLabel>)14 .add('with label', () => <WithLabel label="Label">With Label</WithLabel>);15import React from 'react';16import { storiesOf } from '@storybook/react';17import { WithLabel } from 'storybook-root-decorator';18import { withInfo } from '@storybook/addon-info';19storiesOf('WithLabel', module)20 .addDecorator(21 withInfo({22 styles: {23 infoBody: {24 },25 },26 }),27 .add('default', () => <WithLabel>Default</WithLabel>)28 .add('with label', () => <WithLabel label="Label">With Label</WithLabel>);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithLabel } from 'storybook-root-decorator';2export default {3};4export const Test = () => <div>Test</div>;5Test.story = {6 parameters: {7 },8};9import { addDecorator, addParameters } from '@storybook/react';10import { WithLabel } from 'storybook-root-decorator';11addDecorator(WithLabel);12addParameters({13});14export default {15};16export const Test = () => <div>Test</div>;17import { WithLabel } from 'storybook-root-decorator';18export default {19};20export const Test = () => <div>Test</div>;21Test.story = {22 parameters: {23 },24};25import { addDecorator, addParameters } from '@storybook/react';26import { WithLabel } from 'storybook-root-decorator';27addDecorator(WithLabel);28addParameters({29});30export default {31};32export const Test = () => <div>Test</div>;33import { addDecorator, addParameters } from '@storybook/react';34import { WithLabel } from 'storybook-root-decorator';35addDecorator(WithLabel);36addParameters({37});38import { addDecorator, addParameters } from '@storybook/react';39import { WithLabel } from 'storybook-root-decorator';40addDecorator(WithLabel);41addParameters({42});43import { addons } from '@storybook/addons';44import { WithLabel } from

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { addDecorator } from '@storybook/react';3import { WithLabel } from 'storybook-root-decorator';4import { withKnobs } from '@storybook/addon-knobs';5import { withA11y } from '@storybook/addon-a11y';6import { withInfo } from '@storybook/addon-info';7import { withBackgrounds } from '@storybook/addon-backgrounds';8import { withViewport } from '@storybook/addon-viewport';9import { withConsole } from '@storybook/addon-console';10import { withTests } from '@storybook/addon-jest';11import { withPerformance } from 'storybook-addon-performance';12import { withCssResources } from '@storybook/addon-cssresources';13import { withContexts } from '@storybook/addon-contexts/react';14import { withPaddings } from 'storybook-addon-paddings';15import { withDesign } from 'storybook-addon-designs';16import { withReduxProvider } from './withReduxProvider';17import { withThemeProvider } from './withThemeProvider';18 {19 {20 props: {21 },22 },23 },24 {25 {26 props: {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithLabel } from "storybook-root-decorator";2export default {3};4export const TestWithLabel = () => {5 return <div>Test</div>;6};7TestWithLabel.story = {8 parameters: {9 },10};11import { WithLabel } from "storybook-root-decorator";12export default {13};14export const TestWithLabel = () => {15 return <div>Test</div>;16};17TestWithLabel.story = {18 parameters: {19 },20};21import { WithLabel } from "storybook-root-decorator";22export default {23};24export const TestWithLabel = () => {25 return <div>Test</div>;26};27TestWithLabel.story = {28 parameters: {29 },30};31import { WithLabel } from "storybook-root-decorator";32export default {33};34export const TestWithLabel = () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithLabel } from 'storybook-root-decorator';2import { WithLabel } from 'storybook-root-decorator';3import { WithLabel } from 'storybook-root-decorator';4import { WithLabel } from 'storybook-root-decorator';5import { WithLabel } from 'storybook-root-decorator';6import { WithLabel } from 'storybook-root-decorator';7import { WithLabel } from 'storybook-root-decorator';8import { WithLabel } from 'storybook-root-decorator';9import { WithLabel } from 'storybook-root-decorator';10import { WithLabel } from 'storybook-root-decorator';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { storiesOf } from '@storybook/react';2import { WithLabel } from 'storybook-root-decorator';3storiesOf('Button', module)4 .addDecorator(WithLabel('My Label'))5 .add('with text', () => <button>My Label</button>);6import { configure, addDecorator } from '@storybook/react';7import { WithLabel } from 'storybook-root-decorator';8addDecorator(WithLabel('My Label'));9configure(require.context('../src', true, /\.stories\.js$/), module);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithLabel } from "storybook-root";2import { storiesOf } from "@storybook/react";3import React from "react";4storiesOf("Test", module).add("WithLabel", () => (5));6{7 "scripts": {8 }9}10import { configure, addDecorator } from "@storybook/react";11import { withInfo } from "@storybook/addon-info";12import { withKnobs } from "@storybook/addon-knobs";13import { withA11y } from "@storybook/addon-a11y";14import { withTests } from "@storybook/addon-jest";15import { withOptions } from "@storybook/addon-options";16import { withConsole } from "@storybook/addon-console";17import { withViewport } from "@storybook/addon-viewport";18import { withBackgrounds } from "@storybook/addon-backgrounds";19import { withPerformance } from "storybook-addon-performance";20import { withRoot } from "storybook-root";21addDecorator(withRoot);22addDecorator(withPerformance);23addDecorator(withBackgrounds);24addDecorator(withViewport);25addDecorator((storyFn, context) =>26 withConsole()(storyFn)(context)27);28addDecorator(29 withOptions({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { WithLabel } from 'storybook-root-decorator';2storiesOf('Component', module)3 .addDecorator(WithLabel('component'))4 .add('default', () => <Component />);5import { WithLabel } from 'storybook-root-decorator';6describe('Component', () => {7 it('should render', () => {8 const { getByText } = render(<Component />);9 expect(getByText('component')).toBeInTheDocument();10 });11});12import { WithLabel } from 'storybook-root-decorator';13storiesOf('Component', module)14 .addDecorator(WithLabel('component'))15 .add('default', () => <Component />)16 .add('with text', () => <Component text="test" />);17import { WithLabel } from 'storybook-root-decorator';18describe('Component', () => {19 it('should render', () => {20 const { getByText } = render(<Component />);21 expect(getByText('component')).toBeInTheDocument();22 });23 it('should render with text', () => {24 const { getByText } = render(<Component text="test" />);25 expect(getByText('component with text')).toBeInTheDocument();26 });27});28import { WithLabel } from 'storybook-root-decorator';29storiesOf('Component', module)30 .addDecorator(WithLabel('component'))31 .add('default', () => <Component />)32 .add('with text', () => <Component text="test" />);33import { WithLabel } from 'storybook-root-decorator';34describe('Component', () => {35 it('should render', () => {36 const { getByText } = render(<Component />);37 expect(getByText('component')).toBeInTheDocument();38 });39 it('should render with text', () => {40 const { getByText } = render(<Component

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful