2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-20 01:09:04 +00:00

react demo: test different render modes

This commit is contained in:
Vjacheslav Trushkin 2022-04-13 10:35:10 +03:00
parent 9d6a3dac12
commit bf07abad7f
10 changed files with 57 additions and 29 deletions

View File

@ -48,22 +48,27 @@ p {
.test-row-icons { .test-row-icons {
padding-right: 4px; padding-right: 4px;
} }
.test-row-icons > svg { .test-row-icons > svg,
.test-row-icons > span {
color: #afafaf; color: #afafaf;
display: none; display: none;
} }
.test-row-icons > svg.visible { .test-row-icons > .hidden {
display: none !important;
}
.test-row-icons > .visible {
display: inline-block; display: inline-block;
} }
.test-row-icons > svg.success { .test-row-icons > .success {
color: #327335; color: #327335;
} }
.test-row-icons > svg.failed { .test-row-icons > .failed {
color: #ba3329; color: #ba3329;
} }
/* 24px icon */ /* 24px icon */
.icon-24 svg { .icon-24 svg,
.icon-24 span {
font-size: 24px; font-size: 24px;
line-height: 1; line-height: 1;
vertical-align: -0.25em; vertical-align: -0.25em;
@ -85,7 +90,7 @@ p {
clear: both; clear: both;
} }
.alert svg { .alert :is(svg, span) {
position: absolute; position: absolute;
left: 12px; left: 12px;
top: 50%; top: 50%;
@ -110,17 +115,17 @@ p {
text-decoration: underline; text-decoration: underline;
} }
.checkbox svg { .checkbox :is(svg, span) {
margin-right: 4px; margin-right: 4px;
color: #afafaf; color: #afafaf;
font-size: 24px; font-size: 24px;
line-height: 1em; line-height: 1em;
vertical-align: -0.25em; vertical-align: -0.25em;
} }
.checkbox--checked svg { .checkbox--checked :is(svg, span) {
color: #327335; color: #327335;
} }
.checkbox:hover svg { .checkbox:hover :is(svg, span) {
color: inherit; color: inherit;
} }
@ -130,7 +135,7 @@ p {
} }
/* Inline demo */ /* Inline demo */
.inline-demo svg { .inline-demo :is(svg, span) {
color: #06a; color: #06a;
margin: 0 8px; margin: 0 8px;
position: relative; position: relative;

View File

@ -12,6 +12,11 @@ interface CheckboxProps {
export function Checkbox(props: CheckboxProps) { export function Checkbox(props: CheckboxProps) {
const [checked, setChecked] = useState(props.checked); const [checked, setChecked] = useState(props.checked);
function onClick(event: React.MouseEvent<HTMLElement>) {
event.preventDefault();
setChecked((value) => !value);
}
return ( return (
<div className="checkbox-container"> <div className="checkbox-container">
<a <a
@ -20,9 +25,12 @@ export function Checkbox(props: CheckboxProps) {
'checkbox ' + 'checkbox ' +
(checked ? 'checkbox--checked' : 'checkbox--unchecked') (checked ? 'checkbox--checked' : 'checkbox--unchecked')
} }
onClick={() => setChecked((value) => !value)} onClick={onClick}
> >
<Icon icon={checked ? checkedIcon : uncheckedIcon} /> <Icon
icon={checked ? checkedIcon : uncheckedIcon}
mode={checked ? 'mask' : 'inline'}
/>
{props.text} {props.text}
</a> </a>
<small>{props.hint}</small> <small>{props.hint}</small>

View File

@ -20,11 +20,13 @@ export function InlineDemo() {
id="inline-demo-inline-offline" id="inline-demo-inline-offline"
icon="experiment2" icon="experiment2"
inline={true} inline={true}
mode="style"
/> />
<FullIcon <FullIcon
id="inline-demo-inline-full" id="inline-demo-inline-full"
icon="experiment2" icon="experiment2"
inline={true} inline={true}
mode="style"
/> />
</div> </div>
</section> </section>

View File

@ -6,7 +6,8 @@ export function FullUsageDemo() {
<section className="icon-24"> <section className="icon-24">
<h1>Usage (full module)</h1> <h1>Usage (full module)</h1>
<div> <div>
Icon referenced by name: <Icon icon="mdi:home" /> Icons referenced by name (as SVG, as SPAN):{' '}
<Icon icon="mdi:home" /> <Icon icon="mdi:home" mode="style" />
</div> </div>
<div className="alert"> <div className="alert">
<Icon icon="mdi-light:alert" /> <Icon icon="mdi-light:alert" />

View File

@ -8,17 +8,20 @@ export function FullOfflineUsageDemo() {
<section className="icon-24"> <section className="icon-24">
<h1>Usage (full module, offline mode)</h1> <h1>Usage (full module, offline mode)</h1>
<div> <div>
Icon referenced by name: <Icon icon="demo" /> Icons referenced by name (as SVG, as SPAN): <Icon icon="demo" />
<Icon icon="demo" mode="style" />
</div> </div>
<div> <div>
Icon referenced by object: <Icon icon={accountIcon} /> Icons referenced by object (as SVG, as SPAN):{' '}
<Icon icon={accountIcon} />
<Icon icon={accountIcon} mode="style" />
</div> </div>
<div> <div>
2 icons imported from icon set: <Icon icon="alert1" /> 2 icons imported from icon set: <Icon icon="alert1" />
<Icon icon="link1" /> <Icon icon="link1" mode="style" />
</div> </div>
<div className="alert"> <div className="alert">
<Icon icon={alertIcon} /> <Icon icon={alertIcon} mode="mask" />
Important notice with alert icon! Important notice with alert icon!
</div> </div>
</section> </section>

View File

@ -8,15 +8,18 @@ export function OfflineUsageDemo() {
<section className="icon-24"> <section className="icon-24">
<h1>Usage (offline module)</h1> <h1>Usage (offline module)</h1>
<div> <div>
Icon referenced by name: <Icon icon="demo" /> Icons referenced by name (as SVG, as SPAN): <Icon icon="demo" />
<Icon icon="demo" mode="style" />
</div> </div>
<div> <div>
Icon referenced by object: <Icon icon={accountIcon} /> Icons referenced by object (as SVG, as SPAN):{' '}
<Icon icon={accountIcon} />{' '}
<Icon icon={accountIcon} mode="style" />
</div> </div>
<div> <div>
2 icons imported from icon set:{' '} 2 icons imported from icon set:{' '}
<Icon icon="offline-mdi-light:account-alert" /> <Icon icon="offline-mdi-light:account-alert" />
<Icon icon="offline-mdi-light:link" /> <Icon icon="offline-mdi-light:link" mode="style" />
</div> </div>
<div className="alert"> <div className="alert">
<Icon icon={alertIcon} /> <Icon icon={alertIcon} />

View File

@ -19,18 +19,21 @@ export function TestIcons(props: TestIconsProps) {
<span className="test-row-icons" id={id}> <span className="test-row-icons" id={id}>
<InlineIcon <InlineIcon
icon={successIcon} icon={successIcon}
mode="style"
className={ className={
'success ' + (icon === 'success' ? 'visible' : 'hidden') 'success ' + (icon === 'success' ? 'visible' : 'hidden')
} }
/> />
<InlineIcon <InlineIcon
icon={pendingIcon} icon={pendingIcon}
mode="style"
className={ className={
'pending ' + (icon === 'pending' ? 'visible' : 'hidden') 'pending ' + (icon === 'pending' ? 'visible' : 'hidden')
} }
/> />
<InlineIcon <InlineIcon
icon={failedIcon} icon={failedIcon}
mode="style"
className={ className={
'failed ' + (icon === 'failed' ? 'visible' : 'hidden') 'failed ' + (icon === 'failed' ? 'visible' : 'hidden')
} }

View File

@ -208,12 +208,13 @@ export function TestsFull() {
<div className="test-row"> <div className="test-row">
<TestIcons id="full-color3" /> <TestIcons id="full-color3" />
Green color from attribute (overrides style) + red from style:{' '} Red color from attribute + green from style (style overrides
attribute):{' '}
<InlineIcon <InlineIcon
icon={icon} icon={icon}
color="green" color="red"
style={{ style={{
color: 'red', color: 'green',
}} }}
ref={(element) => { ref={(element) => {
const key = 'full-color3'; const key = 'full-color3';

View File

@ -176,12 +176,13 @@ export function TestsFullOffline() {
<div className="test-row"> <div className="test-row">
<TestIcons id="full-offline-color3" /> <TestIcons id="full-offline-color3" />
Green color from attribute (overrides style) + red from style:{' '} Red color from attribute + green from style (style overrides
attribute):{' '}
<InlineIcon <InlineIcon
icon="demo" icon="demo"
color="green" color="red"
style={{ style={{
color: 'red', color: 'green',
}} }}
ref={(element) => { ref={(element) => {
const key = 'full-offline-color3'; const key = 'full-offline-color3';

View File

@ -176,12 +176,13 @@ export function TestsOffline() {
<div className="test-row"> <div className="test-row">
<TestIcons id="offline-color3" /> <TestIcons id="offline-color3" />
Green color from attribute (overrides style) + red from style:{' '} Red color from attribute + green from style (style overrides
attribute):{' '}
<InlineIcon <InlineIcon
icon="demo" icon="demo"
color="green" color="red"
style={{ style={{
color: 'red', color: 'green',
}} }}
ref={(element) => { ref={(element) => {
const key = 'offline-color3'; const key = 'offline-color3';