|
1 | 1 | <script lang="ts"> |
2 | | - import { P, Span, Button, Label, Radio } from '$lib'; |
| 2 | + import { P, Span, span, Button, Label, Radio } from '$lib'; |
3 | 3 | import HighlightCompo from '../../utils/HighlightCompo.svelte'; |
4 | 4 | import CodeWrapper from '../../utils/CodeWrapper.svelte'; |
5 | 5 | import H1 from '../../utils/H1.svelte'; |
|
12 | 12 | }); |
13 | 13 |
|
14 | 14 | let spanItalic: Span['italic'] = $state(false); |
| 15 | + const changeItalic = () => { |
| 16 | + spanItalic = !spanItalic; |
| 17 | + } |
15 | 18 | let spanUnderline: Span['underline'] = $state(false); |
| 19 | + const changeUnderline = () => { |
| 20 | + spanUnderline = !spanUnderline; |
| 21 | + spanDecorationColor = 'none'; |
| 22 | + spanDecorationThickness = '0'; |
| 23 | + spanDecoration = 'none'; |
| 24 | + spanLinethrough = false; |
| 25 | + } |
16 | 26 | let spanLinethrough: Span['linethrough'] = $state(false); |
| 27 | + const changeLinethrough = () => { |
| 28 | + spanLinethrough = !spanLinethrough; |
| 29 | + spanUnderline = false; |
| 30 | + spanDecorationColor = 'none'; |
| 31 | + spanDecorationThickness = '0'; |
| 32 | + spanDecoration = 'none'; |
| 33 | + spanGradient = 'none'; |
| 34 | + } |
17 | 35 | let spanUppercase: Span['uppercase'] = $state(false); |
18 | | - const gradients = ['skyToEmerald', 'purpleToBlue', 'tealToLime', 'redToYellow', 'indigoToCyan', 'fuchsiaToRose', 'amberToEmerald', 'violetToRed', 'blueToGreen', 'orangeToPurple', 'yellowToRed', 'normal']; |
19 | | - let spanGradient: Span['gradient'] = $state('normal'); |
20 | | - let spanHighlight: Span['highlight'] = $state('blue'); |
21 | | - const highlights = ['blue', 'red', 'green', 'yellow', 'purple', 'pink', 'indigo', 'teal', 'orange', 'cyan', 'fuchsia', 'amber', 'lime']; |
22 | | - let spanDecoration: Span['decoration'] = $state('solid'); |
23 | | - const decorations = ['solid', 'double', 'dotted', 'dashed', 'wavy', 'none']; |
24 | | - let spanDecorationColor: Span['decorationColor'] = $state('blue'); |
25 | | - const decorationColors = ['blue', 'red', 'green', 'yellow', 'purple', 'pink', 'indigo', 'teal', 'orange', 'cyan', 'fuchsia', 'amber', 'lime']; |
26 | | - let spanDecorationThickness: Span['decorationThickness'] = $state('1'); |
27 | | - const docrationThickness = ['1', '2', '4', '8', '0']; |
28 | | -</script> |
| 36 | + const changeUppercase = () => { |
| 37 | + spanUppercase = !spanUppercase; |
| 38 | + } |
| 39 | + const gradients = Object.keys(span.variants.gradient); |
| 40 | + let spanGradient: Span['gradient'] = $state('none'); |
| 41 | + let spanHighlight: Span['highlight'] = $state('none'); |
| 42 | + const highlights = Object.keys(span.variants.highlight); |
| 43 | + let spanDecoration: Span['decoration'] = $state('none'); |
| 44 | + const decorations = Object.keys(span.variants.decoration); |
| 45 | + let spanDecorationColor: Span['decorationColor'] = $state('none'); |
| 46 | + const decorationColors = Object.keys(span.variants.decorationColor); |
| 47 | + let spanDecorationThickness: Span['decorationThickness'] = $state('0'); |
| 48 | + const docrationThickness = Object.keys(span.variants.decorationThickness); |
29 | 49 |
|
30 | | -<H1>Span</H1> |
| 50 | + // code generator |
| 51 | + let generatedCode = $derived( |
| 52 | + (() => { |
| 53 | + let props = []; |
| 54 | + // italic, underline, linethrough, uppercase, gradient, highlight, decoration, decorationColor, decorationThickness, className |
| 55 | + if ( spanItalic ) props.push(` italic`); |
| 56 | + if ( spanUnderline ) props.push(` underline`); |
| 57 | + if ( spanLinethrough ) props.push(` linethrough`); |
| 58 | + if ( spanUppercase ) props.push(` uppercase`); |
| 59 | + if ( spanGradient !== 'none' ) props.push(` gradient="${spanGradient}"`); |
| 60 | + if ( spanHighlight !== 'none' ) props.push(` highlight="${spanHighlight}"`); |
| 61 | + if ( spanDecoration !== 'none' ) props.push(` decoration="${spanDecoration}"`); |
| 62 | + if ( spanDecorationColor !== 'none' ) props.push(` decorationColor="${spanDecorationColor}"`); |
| 63 | + if ( spanDecorationThickness !== '0' ) props.push(` decorationThickness="${spanDecorationThickness}"`); |
31 | 64 |
|
32 | | -<H2>Italic, underline, linethrough, and uppercase</H2> |
33 | | -<CodeWrapper> |
34 | | - <P> |
35 | | - Track work across the enterprise through an open, collaborative platform. |
36 | | - <Span italic={spanItalic} underline={spanUnderline} class="text-red-500">Link issues across Jira</Span> and ingest data from other <Span linethrough={spanLinethrough} uppercase={spanUppercase} class="text-blue-500">software development</Span> tools, so your IT support and operations teams have richer contextual information ... |
37 | | - </P> |
38 | | - <div class="mt-4 flex flex-wrap items-center gap-2 rtl:space-x-reverse"> |
39 | | - <Button onclick={() => (spanItalic = !spanItalic)}>Italic</Button> |
40 | | - <Button onclick={() => (spanUnderline = !spanUnderline)}>Underline</Button> |
41 | | - <Button onclick={() => (spanLinethrough = !spanLinethrough)}>Linethrough</Button> |
42 | | - <Button onclick={() => (spanUppercase = !spanUppercase)}>Uppercase</Button> |
43 | | - </div> |
44 | | -</CodeWrapper> |
45 | | -<HighlightCompo code={modules['./md/italic.md'] as string} /> |
| 65 | + |
| 66 | + const propsString = props.length > 0 ? props.map((prop) => `\n ${prop}`).join('') + '\n' : ''; |
46 | 67 |
|
47 | | -<H2>Gradient</H2> |
48 | | -<CodeWrapper> |
49 | | - <P size="2xl" weight="bold"><Span gradient={spanGradient}>Track work across the enterprise through an open, collaborative platform.</Span></P> |
50 | | - <div class="mt-4 flex flex-wrap space-x-4"> |
51 | | - <Label class="mb-4 w-full font-bold">Gradient:</Label> |
52 | | - {#each gradients as gradient} |
53 | | - <Radio labelClass="w-32 my-1" name="span_gradient" bind:group={spanGradient} value={gradient}>{gradient}</Radio> |
54 | | - {/each} |
55 | | - </div> |
56 | | -</CodeWrapper> |
57 | | -<HighlightCompo code={modules['./md/gradient.md'] as string} /> |
| 68 | + return `<P>Lorem ipsum dolor sit amet. |
| 69 | + <Span${propsString}>Eligendi, nam ea eum provident.</Span> |
| 70 | + Fugiat vitae possimus ipsum a unde, at laboriosam. |
| 71 | +</P>`; |
| 72 | + })() |
| 73 | + ); |
| 74 | +</script> |
58 | 75 |
|
59 | | -<H2>Highlight</H2> |
| 76 | +<H1>Span</H1> |
| 77 | +<HighlightCompo code={modules['./md/setup.md'] as string} /> |
| 78 | + |
| 79 | +<H2>Interactive Span Builder</H2> |
60 | 80 | <CodeWrapper> |
61 | | - <P size="2xl" weight="bold"><Span highlight={spanHighlight}>Track work across the enterprise through an open, collaborative platform.</Span></P> |
62 | | - <div class="mt-4 flex flex-wrap space-x-4"> |
| 81 | + <P size="xl" weight="bold">Lorem ipsum dolor sit amet consectetur adipisicing elit. <Span italic={spanItalic} underline={spanUnderline} linethrough={spanLinethrough} uppercase={spanUppercase} gradient={spanGradient} decoration={spanDecoration} decorationColor={spanDecorationColor} decorationThickness={spanDecorationThickness} highlight={spanHighlight} >Eligendi, nam ea eum provident.</Span> Fugiat vitae possimus ipsum a unde, at laboriosam.</P> |
| 82 | + <div class="flex flex-wrap space-x-4 mb-4 mt-4"> |
63 | 83 | <Label class="mb-4 w-full font-bold">Highlight:</Label> |
64 | 84 | {#each highlights as highlight} |
65 | | - <Radio labelClass="w-32 my-1" name="span_highlight" bind:group={spanHighlight} color={highlight as Span['color']} value={highlight}>{highlight}</Radio> |
| 85 | + <Radio labelClass="w-32 my-1" name="span_highlight" bind:group={spanHighlight} onchange={()=> spanGradient = 'none'} color={highlight as Span['color']} value={highlight}>{highlight}</Radio> |
66 | 86 | {/each} |
67 | 87 | </div> |
68 | | -</CodeWrapper> |
69 | | -<HighlightCompo code={modules['./md/highlight.md'] as string} /> |
70 | | - |
71 | | -<H2>Decoration</H2> |
72 | | -<CodeWrapper> |
73 | | - <P size="2xl" weight="bold"><Span decoration={spanDecoration} decorationColor={spanDecorationColor} decorationThickness={spanDecorationThickness}>Track work across the enterprise through an open, collaborative platform.</Span></P> |
74 | | - <div class="mt-8 flex flex-wrap space-x-4"> |
| 88 | + <div class="flex flex-wrap space-x-4 mb-4"> |
| 89 | + <Label class="mb-4 w-full font-bold">Decoration color:</Label> |
| 90 | + {#each decorationColors as color} |
| 91 | + <Radio labelClass="w-32 my-1" name="p_decoration_color" bind:group={spanDecorationColor} onchange={()=> {spanUnderline = false; spanLinethrough = false}} color={color as Span['decorationColor']} value={color}>{color}</Radio> |
| 92 | + {/each} |
| 93 | + </div> |
| 94 | + <div class="flex flex-wrap space-x-4 mb-4"> |
75 | 95 | <Label class="mb-4 w-full font-bold">Decoration:</Label> |
76 | 96 | {#each decorations as decoration} |
77 | | - <Radio labelClass="w-32 my-1" name="span_decoration" bind:group={spanDecoration} value={decoration}>{decoration}</Radio> |
| 97 | + <Radio labelClass="w-32 my-1" name="span_decoration" bind:group={spanDecoration} onchange={()=> {spanUnderline = false; spanLinethrough = false}} value={decoration}>{decoration}</Radio> |
78 | 98 | {/each} |
79 | 99 | </div> |
80 | | - <div class="mt-4 flex flex-wrap space-x-4"> |
81 | | - <Label class="mb-4 w-full font-bold">Decoration color:</Label> |
82 | | - {#each decorationColors as color} |
83 | | - <Radio labelClass="w-32 my-1" name="p_decoration_color" bind:group={spanDecorationColor} color={color as Span['decorationColor']} value={color}>{color}</Radio> |
| 100 | + <div class="flex flex-wrap space-x-4"> |
| 101 | + <Label class="mb-4 w-full font-bold">Decoration thickness:</Label> |
| 102 | + {#each docrationThickness as thickness} |
| 103 | + <Radio labelClass="w-32 my-1" name="span_decoration_thickness" bind:group={spanDecorationThickness} onchange={()=> {spanUnderline = false; spanLinethrough = false}} value={thickness}>{thickness}</Radio> |
84 | 104 | {/each} |
85 | 105 | </div> |
86 | 106 | <div class="mt-4 flex flex-wrap space-x-4"> |
87 | | - <Label class="mb-4 w-full font-bold">Decoration thickness:</Label> |
88 | | - {#each docrationThickness as thickness} |
89 | | - <Radio labelClass="w-32 my-1" name="span_decoration_thickness" bind:group={spanDecorationThickness} value={thickness}>{thickness}</Radio> |
| 107 | + <Label class="mb-4 w-full font-bold">Gradient:</Label> |
| 108 | + {#each gradients as gradient} |
| 109 | + <Radio labelClass="w-32 my-1" name="span_gradient" bind:group={spanGradient} onchange={()=>spanHighlight = 'none'} value={gradient}>{gradient}</Radio> |
90 | 110 | {/each} |
91 | 111 | </div> |
| 112 | + <div class="mt-4 flex flex-wrap items-center gap-2 rtl:space-x-reverse"> |
| 113 | + <Button class="w-32" onclick={changeItalic}>{spanItalic ? 'No italic' : 'Italic'}</Button> |
| 114 | + <Button class="w-32" color="amber" onclick={changeUnderline}>{ spanUnderline ? 'No underline' : 'Underline'}</Button> |
| 115 | + <Button class="w-40" color="violet" onclick={changeLinethrough}>{spanLinethrough ? 'No linethrough' : 'Linethrough '}</Button> |
| 116 | + <Button class="w-40" color="blue" onclick={changeUppercase}>{spanUppercase ? 'No uppercase' : 'Uppercase'}</Button> |
| 117 | + </div> |
| 118 | + {#snippet codeblock()} |
| 119 | + <HighlightCompo code={generatedCode} /> |
| 120 | + {/snippet} |
92 | 121 | </CodeWrapper> |
93 | 122 |
|
94 | 123 | <H2>Opacity</H2> |
|
99 | 128 | <P size="xl"><Span class="text-blue-600/75 dark:text-blue-500/75">Flowbite app will help you</Span> improve yourself by analysing your everyday life.</P> |
100 | 129 | <P size="xl"><Span class="text-blue-600/50 dark:text-blue-500/50">Flowbite app will help you</Span> improve yourself by analysing your everyday life.</P> |
101 | 130 | <P size="xl"><Span class="text-blue-600/25 dark:text-blue-500/25">Flowbite app will help you</Span> improve yourself by analysing your everyday life.</P> |
| 131 | + {#snippet codeblock()} |
| 132 | + <HighlightCompo code={modules['./md/opacity.md'] as string} /> |
| 133 | + {/snippet} |
102 | 134 | </CodeWrapper> |
103 | | -<HighlightCompo code={modules['./md/opacity.md'] as string} /> |
|
0 commit comments