import { h } from '@stencil/core'
import { iconsDictionary, mggIconsDictionary, svgIconsDictionary } from '@dictionary/icon'
import { useState } from 'react'
import svgIconPackage from '../../../../../svg-icons/package.json'
const urlIcon = `${location.origin}/svg/mi/baseline/email.svg`
const base64IconEncoded = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Im0yMzMtODAgNjUtMjgxTDgwLTU1MGwyODgtMjUgMTEyLTI2NSAxMTIgMjY1IDI4OCAyNS0yMTggMTg5IDY1IDI4MS0yNDctMTQ5TDIzMy04MFoiLz48L3N2Zz4='
const svgIconDecoded = ' '
export default {
title: 'Design / Icon',
argTypes: {
name: {
type: { name: 'string' },
description: 'The name of the icon or a base64 string to render it as an svg',
options: mggIconsDictionary.concat(iconsDictionary).concat(svgIconsDictionary),
control: { type: 'select' },
},
},
}
const Template = args =>
export const Default = Template.bind({})
Default.args = {
name: 'mdi/alien',
class: 'fill-label-blue-05',
}
export const NameBase64 = Template.bind({})
NameBase64.args = {
name: base64IconEncoded,
}
export const NameSVGIcon = Template.bind({})
NameSVGIcon.args = {
name: svgIconDecoded,
}
export const ExternalSVG = Template.bind({})
ExternalSVG.args = {
name: urlIcon,
class: 'fill-label-green-06',
}
export const NoIcon = Template.bind({})
const ButtonTemplate = args =>
{
const pathName = window.location.pathname.replace('/iframe.html', '')
const svgPath = pathName.charAt(pathName.length - 1) === '/' ? `${pathName}svg/` : `${pathName}/svg/`
window.sessionStorage.setItem('mdsIconSvgPath', svgPath)
window.dispatchEvent(new CustomEvent('mdsIconSvgPathUpdate'))
}}>Cliccami
export const StorageTest = ButtonTemplate.bind({})
StorageTest.args = {
name: 'mdi/alien',
class: 'fill-label-green-05',
}
const ListIconsTemplate = () => {
const [filteredIcons, setFilteredIcons] = useState(mggIconsDictionary)
return
La seguente è una lista delle icone presenti nel pacchetto @maggioli-design-system/svg-icons {svgIconPackage.version} , facente riferimento alle icone di Maggioli
Oltre a questo set, @maggioli-design-system/icons fa uso anche delle librerie di Material Icons e Material Design Icons , la cui lista può essere consultata sui relativi siti.
{
const _filter = (event.target as HTMLMdsInputElement).value ?? ''
if (!_filter) {
setFilteredIcons([...mggIconsDictionary])
return
}
setFilteredIcons(mggIconsDictionary.filter(item => item.includes(_filter)))
}} />
{filteredIcons.map(icon =>
{icon}
)}
}
export const ListIcons = ListIconsTemplate.bind({})