@mui/material#Icon TypeScript Examples
The following examples show how to use
@mui/material#Icon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Files.tsx From NekoMaid with MIT License | 5 votes |
Item: React.FC<{ plugin: Plugin, path: string, loading: Record<string, () => Promise<void>>, dirs: Record<string, boolean> }> =
({ dirs, plugin, path, loading }) => {
const [open, setOpen] = useState(false)
const [files, setFiles] = useState<[string[], string[]] | undefined>()
const load = () => new Promise<void>(resolve => plugin.emit('files:fetch', (data: [string[], string[]]) => {
setFiles(data)
resolve()
if (typeof ''.localeCompare === 'function') {
data[0].sort((a, b) => a.localeCompare(b))
data[1].sort((a, b) => a.localeCompare(b))
}
data[1].forEach((it: string) => (dirs[path + '/' + it] = false))
}, path))
useEffect(() => {
dirs[path] = true
if (path) loading[path] = load; else load()
}, [])
const children = files
? files[0].map(it => <Item plugin={plugin} key={it} path={path ? path + '/' + it : it} loading={loading} dirs={dirs} />)
.concat(files[1].map(it => {
let id = (icons as any).files[it]
if (id == null) {
const parts = it.split('.')
id = (icons as any).extensions[parts[parts.length - 1]]
}
return <StyledTreeItem
key={it}
nodeId={path + '/' + it}
label={<><Icon className='icon'>
<embed src={`/icons/material/${icons.icons[id] || 'file'}.svg`} />
</Icon>{it}</>}
/>
}))
: <StyledTreeItem key={0} nodeId={path + '/.'} label='' />
const paths = path.split('/')
const name = paths[paths.length - 1]
return path
? <StyledTreeItem nodeId={path} onClick={() => setOpen(!open)} label={<>
<Icon className='icon'>
<embed src={`/icons/material/${icons.icons[(icons as any).folders[name]] || 'folder'}${open ? '-open' : ''}.svg`} />
</Icon>{name}
</>}>{children}</StyledTreeItem>
: <>{children}</>
}
Example #2
Source File: CircleCheckboxField.tsx From frontend with MIT License | 5 votes |
export default function CircleCheckboxField({ name, label, labelProps }: CircleCheckboxField) {
const { t } = useTranslation('one-time-donation')
const [field, meta] = useField(name)
const helperText = meta.touched ? translateError(meta.error as TranslatableField, t) : ''
return (
<FormControl required component="fieldset" error={Boolean(meta.error) && Boolean(meta.touched)}>
<FormControlLabel
sx={
field.checked
? {
background: lighten(theme.palette.primary.main, 0.8),
border: `1px solid ${theme.borders.light}`,
}
: undefined
}
label={<Typography sx={{ fontWeight: 'bold', ml: 1 }}>{label}</Typography>}
control={
<Checkbox
icon={
<Icon
sx={(theme) => ({
width: 30,
height: 30,
border: `1px solid ${theme.palette.primary.dark}`,
// @ts-expect-error theme doesn't include overrides
borderRadius: theme.borders.round,
})}
/>
}
checkedIcon={
<CheckIcon
sx={(theme) => ({
width: 30,
height: 30,
border: `1px solid ${theme.palette.primary.main}`,
backgroundColor: theme.palette.primary.main,
// @ts-expect-error theme doesn't include overrides
borderRadius: theme.borders.round,
color: '#fff',
})}
/>
}
checked={Boolean(field.value)}
{...field}
/>
}
{...labelProps}
/>
{Boolean(meta.error) && (
<FormHelperText error>{helperText ? t(helperText) : 'General Error'}</FormHelperText>
)}
</FormControl>
)
}