import * as React from 'react'; import * as _ from 'lodash'; import { Link } from 'react-router-dom'; import { SvgIconProps, Input, Flex, Card, Box, Text, Header, Dropdown, Checkbox, Divider, SizeValue, } from '@fluentui/react-northstar'; import * as exports from '@fluentui/react-icons-northstar'; import { CodeSnippet, CopyToClipboard } from '@fluentui/docs-components'; import GuidesNavigationFooter from '../components/GuidesNavigationFooter'; import ComponentPlaygroundSnippet from '../../src/components/ComponentPlayground/ComponentPlaygroundSnippet'; const iconFlexStyles = { '> *:nth-child(5n)': { marginRight: '0px', }, }; const cardsStyles = { background: 'white', minHeight: 330, overflow: 'unset', }; const icons = Object.keys(exports).reduce((acc: React.FC[], exportName) => { if (!!exports[exportName].displayName) { acc.push(exports[exportName]); } return acc; }, []); const exampleCode = ` import { QnaIcon } from '@fluentui/react-icons-northstar'; const Example = () => ( <> ) `; const IntroCard = props => { const { QnaIcon } = exports; return ( Just add the @fluentui/react-icons-northstar package and choose from over 200 customizable icons. } />
Checkout our{' '} icon {' '} docs for more examples!
); }; interface PlaygroundAction { type: 'toggle_bordered' | 'toggle_circular' | 'toggle_outline' | 'change_rotate' | 'change_size'; value?: SizeValue | number; } interface PlaygroundCardState { bordered: boolean; circular: boolean; outline: boolean; rotate: number; size: SizeValue; } const playgroundStateReducer = (state: PlaygroundCardState, action: PlaygroundAction) => { switch (action.type) { case 'toggle_bordered': return { ...state, bordered: !state.bordered }; case 'toggle_outline': return { ...state, outline: !state.outline }; case 'toggle_circular': return { ...state, circular: !state.circular }; case 'change_rotate': return { ...state, rotate: action.value as number }; case 'change_size': return { ...state, size: action.value as SizeValue }; default: throw new Error(`Action ${action.type} is not supported`); } }; const PlaygroundCard = props => { const { QnaIcon, EditIcon } = exports; const [state, dispatch] = React.useReducer(playgroundStateReducer, { bordered: false, circular: false, outline: false, rotate: 0, size: 'largest', }); const element = ( ); return (
dispatch({ type: 'toggle_outline' })} />
dispatch({ type: 'toggle_bordered' })} />
dispatch({ type: 'toggle_circular' })} />
Rotate
dispatch({ type: 'change_rotate', value: Number(data.value) })} />
Size dispatch({ type: 'change_size', value: d.value.toString() as SizeValue })} />
{element}
); }; const IconViewer = () => { const [query, setQuery] = React.useState(''); const { SearchIcon } = exports; const escapedQuery = _.escapeRegExp(query); const regexQuery = new RegExp(`.*${escapedQuery}`, 'i'); const handleQueryChange = (e, data) => { setQuery(data.value); }; const filteredIcons = icons.filter(IconComponent => regexQuery.test(IconComponent.displayName)); return (
} placeholder={`Search across ${icons.length} icons`} iconPosition="end" role="search" onChange={handleQueryChange} value={query} /> {filteredIcons.map(Icon => (
`} timeout={3000}> {(active, onClick) => ( {active ? 'Copied! Happy coding :)' : `<${Icon.displayName} />`} )}
))}
); }; export default IconViewer;