2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-08 15:54:09 +00:00

Rename inline mode to svg in components

This commit is contained in:
Vjacheslav Trushkin 2022-04-30 18:23:38 +03:00
parent 4601d540ef
commit f4efa1853d
15 changed files with 49 additions and 43 deletions

View File

@ -29,7 +29,7 @@ export function Checkbox(props: CheckboxProps) {
> >
<Icon <Icon
icon={checked ? checkedIcon : uncheckedIcon} icon={checked ? checkedIcon : uncheckedIcon}
mode={checked ? 'mask' : 'inline'} mode={checked ? 'mask' : 'svg'}
/> />
{props.text} {props.text}
</a> </a>

View File

@ -13,12 +13,12 @@
<Counter /> <Counter />
<p> <p>
Visit <a href="https://svelte.dev">svelte.dev <Icon icon="ci:external-link" inline={true} /></a> to learn how to build <Icon icon="logos:svelte" inline={true} /> Visit <a href="https://svelte.dev">svelte.dev <Icon icon="ci:external-link" inline={true} mode="style" /></a> to learn how to build <Icon icon="logos:svelte" inline={true} />
apps. apps.
</p> </p>
<p> <p>
Check out <a href="https://github.com/sveltejs/kit#readme">SvelteKit <Icon icon="ci:external-link" inline={true} /></a> for Check out <a href="https://github.com/sveltejs/kit#readme">SvelteKit <Icon icon="ci:external-link" inline={true} mode="style" /></a> for
the officially supported framework, also powered by Vite! the officially supported framework, also powered by Vite!
</p> </p>
</main> </main>

View File

@ -48,22 +48,22 @@ p {
.test-row-icons { .test-row-icons {
padding-right: 4px; padding-right: 4px;
} }
.test-row-icons > svg { .test-row-icons > :is(svg, span) {
color: #afafaf; color: #afafaf;
display: none; display: none;
} }
.test-row-icons > svg.visible { .test-row-icons > :is(svg, span).visible {
display: inline-block; display: inline-block;
} }
.test-row-icons > svg.success { .test-row-icons > :is(svg, span).success {
color: #327335; color: #327335;
} }
.test-row-icons > svg.failed { .test-row-icons > :is(svg, span).failed {
color: #ba3329; color: #ba3329;
} }
/* 24px icon */ /* 24px icon */
.icon-24 svg { .icon-24 :is(svg, span) {
font-size: 24px; font-size: 24px;
line-height: 1; line-height: 1;
vertical-align: -0.25em; vertical-align: -0.25em;
@ -85,7 +85,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 +110,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 +130,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

@ -23,6 +23,6 @@
</script> </script>
<div class="checkbox-container"> <div class="checkbox-container">
<a href="# " class={className} on:click|preventDefault={toggle}><Icon icon={icon} />{text}</a> <a href="# " class={className} on:click|preventDefault={toggle}><Icon icon={icon} mode={checked ? 'svg' : 'style'} />{text}</a>
<small>{hint}</small> <small>{hint}</small>
</div> </div>

View File

@ -8,11 +8,15 @@
<div> <div>
Block icon (behaving like image): Block icon (behaving like image):
<OfflineIcon icon="experiment2" /> <OfflineIcon icon="experiment2" />
<OfflineIcon icon="experiment2" mode="style" />
<FullIcon icon="experiment2" /> <FullIcon icon="experiment2" />
<FullIcon icon="experiment2" mode="style" />
</div> </div>
<div> <div>
Inline icon (behaving line text / icon font): Inline icon (behaving line text / icon font):
<OfflineIcon icon="experiment2" inline={true} /> <OfflineIcon icon="experiment2" inline={true} />
<OfflineIcon icon="experiment2" inline={true} mode="style" />
<FullIcon icon="experiment2" inline={true} /> <FullIcon icon="experiment2" inline={true} />
<FullIcon icon="experiment2" inline={true} mode="style" />
</div> </div>
</section> </section>

View File

@ -7,13 +7,13 @@
<section class="icon-24"> <section class="icon-24">
<h1>Usage (full module)</h1> <h1>Usage (full module)</h1>
<div> <div>
Icon referenced by name: <Icon icon="mdi:home" /> Icon referenced by name (as svg, as span): <Icon icon="mdi:home" mode="svg" /><Icon icon="mdi:home" mode="style" />
</div> </div>
<div class="alert"> <div class="alert">
<Icon icon="mdi-light:alert" on:load={event => { <Icon icon="mdi-light:alert" on:load={event => {
console.log(event); console.log(event);
onLoadCalled = true; onLoadCalled = true;
}} /> }} mode="style" />
Important notice with alert icon{onLoadCalled ? '' : ' (loading...)'}! Important notice with alert icon{onLoadCalled ? '' : ' (loading...)'}!
</div> </div>
</section> </section>

View File

@ -3,7 +3,7 @@
<span :class="className"> <span :class="className">
<Icon <Icon
:icon="icon" :icon="icon"
:mode="isChecked ? 'inline' : 'style'" :mode="isChecked ? 'svg' : 'style'"
@click="check" @click="check"
/>{{ text }} />{{ text }}
</span> </span>

View File

@ -11,11 +11,11 @@ export const inlineClass = 'iconify-inline';
* Icon render mode * Icon render mode
* *
* 'style' = 'bg' or 'mask', depending on icon content * 'style' = 'bg' or 'mask', depending on icon content
* 'bg' = inline style using `background` * 'bg' = add inline style to placeholder using `background`
* 'mask' = inline style using `mask` * 'mask' = add inline style to placeholder using `mask`
* 'inline' = inline SVG. * 'svg' = <svg>
*/ */
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'inline'; export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
/** /**
* Data used to verify if icon is the same * Data used to verify if icon is the same

View File

@ -8,11 +8,11 @@ export { RawIconCustomisations };
* Icon render mode * Icon render mode
* *
* 'style' = 'bg' or 'mask', depending on icon content * 'style' = 'bg' or 'mask', depending on icon content
* 'bg' = inline style using `background` * 'bg' = <span> with style using `background`
* 'mask' = inline style using `mask` * 'mask' = <span> with style using `mask`
* 'inline' = inline SVG. * 'svg' = <svg>
*/ */
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'inline'; export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
// Allow rotation to be string // Allow rotation to be string
/** /**

View File

@ -91,7 +91,7 @@ export const render = (
); );
// Check mode // Check mode
const mode: IconifyRenderMode = props.mode || 'inline'; const mode: IconifyRenderMode = props.mode || 'svg';
// Create style // Create style
const style: React.CSSProperties = {}; const style: React.CSSProperties = {};
@ -99,7 +99,7 @@ export const render = (
// Create SVG component properties // Create SVG component properties
const componentProps = { const componentProps = {
...(mode === 'inline' ? svgDefaults : {}), ...(mode === 'svg' ? svgDefaults : {}),
ref, ref,
}; };
@ -181,7 +181,7 @@ export const render = (
style.verticalAlign = '-0.125em'; style.verticalAlign = '-0.125em';
} }
if (mode === 'inline') { if (mode === 'svg') {
// Add style // Add style
componentProps.style = { componentProps.style = {
...style, ...style,

View File

@ -125,6 +125,7 @@ export { RawIconCustomisations, IconifyIconBuildResult };
/* Browser cache */ /* Browser cache */
export { IconifyBrowserCacheType }; export { IconifyBrowserCacheType };
/** /**
* Enable cache * Enable cache
*/ */

View File

@ -7,11 +7,11 @@ export { RawIconCustomisations };
* Icon render mode * Icon render mode
* *
* 'style' = 'bg' or 'mask', depending on icon content * 'style' = 'bg' or 'mask', depending on icon content
* 'bg' = inline style using `background` * 'bg' = <span> with style using `background`
* 'mask' = inline style using `mask` * 'mask' = <span> with style using `mask`
* 'inline' = inline SVG. * 'svg' = <svg>
*/ */
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'inline'; export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
// Allow rotation to be string // Allow rotation to be string
/** /**

View File

@ -86,10 +86,11 @@ export function render(
); );
// Check mode // Check mode
const mode: IconifyRenderMode = props.mode || 'inline'; const mode: IconifyRenderMode = props.mode || 'svg';
const componentProps = ( const componentProps = (mode === 'svg' ? { ...svgDefaults } : {}) as Record<
mode === 'inline' ? { ...svgDefaults } : {} string,
) as Record<string, unknown>; unknown
>;
// Create style if missing // Create style if missing
let style = typeof props.style === 'string' ? props.style : ''; let style = typeof props.style === 'string' ? props.style : '';
@ -181,7 +182,7 @@ export function render(
style = 'vertical-align: -0.125em; ' + style; style = 'vertical-align: -0.125em; ' + style;
} }
if (mode === 'inline') { if (mode === 'svg') {
// Add icon stuff // Add icon stuff
Object.assign(componentProps, renderAttribs); Object.assign(componentProps, renderAttribs);

View File

@ -7,11 +7,11 @@ export { RawIconCustomisations };
* Icon render mode * Icon render mode
* *
* 'style' = 'bg' or 'mask', depending on icon content * 'style' = 'bg' or 'mask', depending on icon content
* 'bg' = inline style using `background` * 'bg' = <span> with style using `background`
* 'mask' = inline style using `mask` * 'mask' = <span> with style using `mask`
* 'inline' = inline SVG. * 'svg' = <svg>
*/ */
export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'inline'; export type IconifyRenderMode = 'style' | 'bg' | 'mask' | 'svg';
// Allow rotation to be string // Allow rotation to be string
/** /**

View File

@ -111,7 +111,7 @@ export const render = (
const componentProps = { ...svgDefaults }; const componentProps = { ...svgDefaults };
// Check mode // Check mode
const mode: IconifyRenderMode = props.mode || 'inline'; const mode: IconifyRenderMode = props.mode || 'svg';
// Copy style // Copy style
const style: VStyle = {}; const style: VStyle = {};
@ -213,7 +213,7 @@ export const render = (
style.verticalAlign = '-0.125em'; style.verticalAlign = '-0.125em';
} }
if (mode === 'inline') { if (mode === 'svg') {
// Add style // Add style
componentProps.style = { componentProps.style = {
...style, ...style,