|
|
@@ -1,162 +1,201 @@
|
|
|
<!-- Radio Demo -->
|
|
|
<script>
|
|
|
- import { RadioGroup, Radio, Divider, Button } from '../../../../../packages/stdf/components';
|
|
|
+ import { Radio, Divider, Button, Icon } from '../../../../../packages/stdf/components';
|
|
|
|
|
|
const dota = [
|
|
|
- { label: 'Jugg', name: 'Juggernaut', desc: 'The master is a melee agile hero, and he can quickly cut into the battle.' },
|
|
|
- { label: 'SB', name: 'Spirit Breaker', desc: 'Barlason, the soul -cracked man is a powerful Gank -type melee hero.' },
|
|
|
- { label: 'Kotl', name: 'Keeper of the Light', desc: 'Izalo, Guardian of Light, he is a famous auxiliary intellectual hero.' },
|
|
|
- { label: 'Mag', name: 'Magnus', desc: 'Mighty? Why not BAN mighty? Why not BAN mighty?' },
|
|
|
+ { label: 'Jugg', name: 'Juggernaut', desc: 'Juggernaut is a melee agility hero who can quickly engage in combat.' },
|
|
|
+ { label: 'SB', name: 'Spirit Breaker', desc: 'Barathrum, Spirit Breaker is a powerful ganking strength melee hero.' },
|
|
|
+ { label: 'KOTL', name: 'Keeper of the Light', desc: 'Ezalor, Keeper of the Light, is a famous support intelligence hero.' },
|
|
|
+ { label: 'Mag', name: 'Magnus', desc: 'Magnus? Why not ban Magnus? Why not ban Magnus?' },
|
|
|
];
|
|
|
- let value = dota[0].name;
|
|
|
- const dotaFun = e => {
|
|
|
- value = e.detail;
|
|
|
- };
|
|
|
- const dotaImgs = ['Lina', 'ES', 'Mor', 'Sni', 'SV'];
|
|
|
- const dotaForImgs = ['火女', '小牛', '水人', '火枪', '斯温'];
|
|
|
- let imgValue = dotaImgs[3];
|
|
|
- const dotaImgsFun = e => {
|
|
|
- imgValue = e.detail;
|
|
|
- };
|
|
|
+ let value = $state(dota[0].name);
|
|
|
+ let checkedsCustom = $state('');
|
|
|
+
|
|
|
+ const dotaInlines = [
|
|
|
+ { label: 'Lina', name: 'Lina' },
|
|
|
+ { label: 'SB', name: 'Spirit Breaker' },
|
|
|
+ { label: 'Morph', name: 'Morphling' },
|
|
|
+ { label: 'Sniper', name: 'Sniper' },
|
|
|
+ { label: 'Sven', name: 'Sven' },
|
|
|
+ { label: 'Invoker', name: 'Invoker' },
|
|
|
+ { label: 'Tide', name: 'Tidehunter' },
|
|
|
+ { label: 'Bat', name: 'Batrider' },
|
|
|
+ { label: 'Mag', name: 'Magnus' },
|
|
|
+ ];
|
|
|
+ let checkInline = $state('Morphling');
|
|
|
+
|
|
|
+ const dotaImgs = [
|
|
|
+ { label: 'Lina', name: 'Lina', imgName: '火女' },
|
|
|
+ { label: 'SB', name: 'Spirit Breaker', imgName: '小牛' },
|
|
|
+ { label: 'Morph', name: 'Morphling', imgName: '水人' },
|
|
|
+ { label: 'Sniper', name: 'Sniper', imgName: '火枪' },
|
|
|
+ { label: 'Sven', name: 'Sven', imgName: '斯温' },
|
|
|
+ ];
|
|
|
+ let imgChecked = $state('Lina');
|
|
|
+
|
|
|
+ const dotaLong = [
|
|
|
+ { name: 'Jugg', label: 'Juggernaut is a melee agility hero who can quickly engage in combat.' },
|
|
|
+ { name: 'SB', label: 'Barathrum, Spirit Breaker is a powerful ganking strength melee hero.' },
|
|
|
+ { name: 'KOTL', label: 'Ezalor, Keeper of the Light, is a famous support intelligence hero.' },
|
|
|
+ { name: 'Mag', label: 'Magnus? Why not ban Magnus? Why not ban Magnus?' },
|
|
|
+ ];
|
|
|
+
|
|
|
const dotaVoices = [
|
|
|
- { label: 'karl', name: 'karl', voices: ['"From the great mystery."'] },
|
|
|
- { label: 'Storm', name: 'Storm', voices: ['"Hey ~ Quickly wake up, drink coffee, we are attacked on the tower."'] },
|
|
|
+ { name: 'Invoker', label: 'Invoker', voices: ['"From the first point was begat a line."'] },
|
|
|
+ { name: 'Storm', label: 'Storm', voices: ['"Hey, wake up! Get some coffee, our tower is under attack."'] },
|
|
|
{
|
|
|
- label: 'Bat',
|
|
|
- name: 'Bat',
|
|
|
+ name: 'Batrider',
|
|
|
+ label: 'Batrider',
|
|
|
voices: [
|
|
|
- '"Oh, Lina, what about Mrs. My Village?"',
|
|
|
- "'Oh, popular, you don't have to run when you see me.'",
|
|
|
- '"Crystal room woman, you are like a tall cup full of ice water."',
|
|
|
+ '"Oh Lina, wanna be my queen?"',
|
|
|
+ '"Oh Windrunner, no need to run from me."',
|
|
|
+ '"Crystal Maiden, you\'re like a tall glass of water."',
|
|
|
],
|
|
|
},
|
|
|
- { label: 'Tide', name: 'Tide', voices: ['"I can still eat a seaweed."'] },
|
|
|
+ { name: 'Tidehunter', label: 'Tidehunter', voices: ['"I could eat a sea cucumber."'] },
|
|
|
];
|
|
|
- let voiceValue = dotaVoices[0].name;
|
|
|
- const dotaVoicesFun = e => {
|
|
|
- voiceValue = e.detail;
|
|
|
- };
|
|
|
+ let voiceChecked = $state('');
|
|
|
</script>
|
|
|
|
|
|
<div class="px-4">
|
|
|
- <div class="mt-8 mb-4 font-bold text-2xl">Horizontal arrangement</div>
|
|
|
- <div class="mt-6 mb-4 font-bold text-lg">Simple usage</div>
|
|
|
- <RadioGroup {value} horizontal>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name}>{item.label}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">The text is in different places</div>
|
|
|
- <RadioGroup {value} horizontal>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name} textPosition="l">{item.label}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
+ <div class="mt-8 mb-4 font-bold text-2xl">Horizontal Layout</div>
|
|
|
+ <div class="mt-6 mb-4 font-bold text-lg">Basic Usage</div>
|
|
|
+ <Radio layout="h" data={dota} />
|
|
|
<Divider />
|
|
|
- <RadioGroup {value} horizontal>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name} textPosition="b">{item.label}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
+
|
|
|
+ <div class="mt-6 mb-4 font-bold text-lg">Get Selected Value</div>
|
|
|
+ <Radio layout="h" data={dota} bind:value />
|
|
|
+ <div class="mt-4 text-sm">Selected: {value}</div>
|
|
|
<Divider />
|
|
|
- <RadioGroup {value} horizontal>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name} textPosition="t">{item.label}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Custom icon</div>
|
|
|
- <RadioGroup value="Juggernaut" horizontal>
|
|
|
- <Radio icon={{ name: 'ri-checkbox-line' }} iconChecked={{ name: 'ri-checkbox-fill' }} name="Juggernaut">Jugg</Radio>
|
|
|
- <Radio icon={{ name: 'ri-checkbox-circle-line' }} iconChecked={{ name: 'ri-checkbox-circle-fill' }} name="Spirit Breaker">SB</Radio>
|
|
|
- <Radio icon={{ name: 'ri-checkbox-multiple-line' }} iconChecked={{ name: 'ri-checkbox-multiple-fill' }} name="Keeper of the Light"
|
|
|
- >Kotl</Radio
|
|
|
- >
|
|
|
- <Radio icon={{ name: 'ri-check-line' }} iconChecked={{ name: 'ri-check-fill' }} name="Magnus">Mag</Radio>
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Picture option</div>
|
|
|
- <RadioGroup value={imgValue} horizontal on:change={dotaImgsFun}>
|
|
|
- {#each dotaImgs as dota, i}
|
|
|
- <Radio name={dota} textPosition="t" icon={{ name: 'ri-arrow-up-s-line' }} iconChecked={{ name: 'ri-arrow-up-s-fill', size: 30 }}>
|
|
|
- <div class={`w-12 h-12 mb-1 rounded overflow-hidden ${imgValue === dota && 'ring-2 ring-primary dark:ring-dark'}`}>
|
|
|
- <img class="w-full h-full object-cover" src={`/assets/images/dota_${dotaForImgs[i]}.png`} alt="" />
|
|
|
- </div>
|
|
|
- </Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
- <div class="text-sm">What, are you choosing again <span class="text-[red] font-bold text-lg">{imgValue}!!</span></div>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">No icon && use Button</div>
|
|
|
- <RadioGroup {value} horizontal on:change={dotaFun}>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name} icon="none" iconChecked="none">
|
|
|
- <Button fill={value === item.name ? 'base' : 'lineLight'} heightIn="0">{item.label}</Button>
|
|
|
- </Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">No icon && Customize the selection effect</div>
|
|
|
- <RadioGroup {value} horizontal on:change={dotaFun}>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name} icon="none" iconChecked="none">
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Text Position</div>
|
|
|
+ <Radio layout="h" data={dota} textPosition="l" />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} textPosition="b" />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} textPosition="t" />
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Custom Icon</div>
|
|
|
+ <Radio layout="h" data={dota} icon={{ name: 'ri-checkbox-blank-circle-line' }} iconChecked={{ name: 'ri-radio-button-fill' }} />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} icon={{ name: 'ri-checkbox-circle-line' }} iconChecked={{ name: 'ri-checkbox-circle-fill' }} />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} icon={{ name: 'ri-checkbox-multiple-line' }} iconChecked={{ name: 'ri-checkbox-multiple-fill' }} />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} icon={{ name: 'ri-check-line' }} iconChecked={{ name: 'ri-check-fill' }} />
|
|
|
+ <Divider />
|
|
|
+ <Radio layout="h" data={dota} icon={{ name: 'ri-check-double-line' }} iconChecked={{ name: 'ri-check-double-line' }} />
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Snippet as Button Component</div>
|
|
|
+ <Radio layout="h" data={dota}>
|
|
|
+ {#snippet radioChild({ item })}
|
|
|
+ <Button fill={value === item.name ? 'base' : 'lineLight'} injClass="px-2 !py-1" onclick={() => (value = item.name)}>
|
|
|
+ {item.label}
|
|
|
+ </Button>
|
|
|
+ {/snippet}
|
|
|
+ </Radio>
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Snippet as Custom Element</div>
|
|
|
+ <Radio layout="h" data={dota}>
|
|
|
+ {#snippet radioChild({ item })}
|
|
|
+ <button
|
|
|
+ class="border py-0.5 px-5 text-sm rounded {checkedsCustom === item.name
|
|
|
+ ? 'text-primary dark:text-dark bg-primary/10 dark:bg-dark/10'
|
|
|
+ : 'bg-gray-100 dark:bg-gray-600 border-gray-200 dark:border-gray-500'}"
|
|
|
+ onclick={() => (checkedsCustom = item.name)}
|
|
|
+ >
|
|
|
+ {item.label}
|
|
|
+ </button>
|
|
|
+ {/snippet}
|
|
|
+ </Radio>
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Image Options</div>
|
|
|
+ <Radio layout="h" data={dotaImgs}>
|
|
|
+ {#snippet radioChild({ item })}
|
|
|
+ <div class="flex flex-col items-center">
|
|
|
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
|
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
|
<div
|
|
|
- class={`border py-0.5 px-5 text-sm rounded ${
|
|
|
- value === item.name
|
|
|
- ? 'text-primary dark:text-dark bg-primary/10 dark:bg-dark/10'
|
|
|
- : 'bg-gray-100 dark:bg-gray-600 border-gray-200 dark:border-gray-500'
|
|
|
- }`}
|
|
|
+ class="w-12 h-12 mb-1 rounded overflow-hidden {imgChecked === item.name ? 'ring-2 ring-primary dark:ring-dark' : ''}"
|
|
|
+ onclick={() => (imgChecked = item.name)}
|
|
|
>
|
|
|
- {item.label}
|
|
|
+ <img class="w-full h-full object-cover" src={`/assets/images/dota_${item.imgName}.png`} alt="" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Icon
|
|
|
+ name={imgChecked === item.name ? 'ri-arrow-up-s-fill' : 'ri-arrow-up-s-line'}
|
|
|
+ theme={imgChecked === item.name}
|
|
|
+ alpha={imgChecked === item.name ? 1 : 0.2}
|
|
|
+ />
|
|
|
</div>
|
|
|
- </Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
+ </div>
|
|
|
+ {/snippet}
|
|
|
+ </Radio>
|
|
|
+ <div class="text-sm">
|
|
|
+ Selected <span class="text-[red]">{imgChecked}</span>
|
|
|
+ </div>
|
|
|
+ <Divider />
|
|
|
+</div>
|
|
|
+
|
|
|
+<div class="px-4">
|
|
|
+ <div class="mb-4 font-bold text-2xl">Inline Layout</div>
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Snippet Inline Layout</div>
|
|
|
+ <Radio layout="inline" data={dotaInlines}>
|
|
|
+ {#snippet radioChild({ item })}
|
|
|
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
|
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
|
+ <div
|
|
|
+ class="border py-0.5 px-2 m-1 text-sm rounded {checkInline === item.name
|
|
|
+ ? 'text-primary dark:text-dark bg-primary/10 dark:bg-dark/10'
|
|
|
+ : 'bg-gray-100 dark:bg-gray-600 border-gray-200 dark:border-gray-500'}"
|
|
|
+ onclick={() => (checkInline = item.name)}
|
|
|
+ >
|
|
|
+ {item.label}
|
|
|
+ </div>
|
|
|
+ {/snippet}
|
|
|
+ </Radio>
|
|
|
+ <div class="text-xs mt-2">Selected: {checkInline}</div>
|
|
|
</div>
|
|
|
<Divider />
|
|
|
+
|
|
|
<div class="px-4 pb-8">
|
|
|
- <div class="mb-4 font-bold text-2xl">Longitudinal arrangement</div>
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Basic usage</div>
|
|
|
- <RadioGroup {value}>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name}>{item.label}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Long text option</div>
|
|
|
- <RadioGroup {value}>
|
|
|
- {#each dota as item}
|
|
|
- <Radio name={item.name}>{item.desc}</Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Text to the left</div>
|
|
|
- <RadioGroup {value}>
|
|
|
- {#each dota as item, i}
|
|
|
- <Radio name={item.name} textPosition="l">
|
|
|
- {item.label}
|
|
|
- {#if i !== dota.length - 1}
|
|
|
- <div class="h-px mt-1 bg-gray-100 dark:bg-gray-800" />
|
|
|
- {/if}
|
|
|
- </Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
-
|
|
|
- <div class="mt-8 mb-4 font-bold text-lg">Complex option && Customize the selection effect</div>
|
|
|
- <RadioGroup value={voiceValue} on:change={dotaVoicesFun}>
|
|
|
- {#each dotaVoices as item, i}
|
|
|
- <Radio name={item.name}>
|
|
|
- <div class={`ml-2 ${voiceValue === item.name ? 'text-primary dark:text-dark' : ''}`}>
|
|
|
+ <div class="mb-4 font-bold text-2xl">Vertical Layout</div>
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Basic Usage</div>
|
|
|
+ <Radio data={dota} />
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Long Text Options</div>
|
|
|
+ <Radio data={dotaLong} />
|
|
|
+ <Divider />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Text Position</div>
|
|
|
+ <Radio data={dota} textPosition="l" />
|
|
|
+
|
|
|
+ <div class="mt-8 mb-4 font-bold text-lg">Complex Options && Custom Selected Effect</div>
|
|
|
+ <Radio data={dotaVoices}>
|
|
|
+ {#snippet radioChild({ item })}
|
|
|
+ <!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
|
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
|
+ <div class="flex items-center cursor-pointer" onclick={() => (voiceChecked = item.name)}>
|
|
|
+ <div>
|
|
|
+ <Icon
|
|
|
+ name={voiceChecked === item.name ? 'ri-radio-button-line' : 'ri-checkbox-blank-circle-line'}
|
|
|
+ theme={voiceChecked === item.name}
|
|
|
+ alpha={voiceChecked === item.name ? 1 : 0.2}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="ml-2 grow {voiceChecked === item.name ? 'text-primary dark:text-dark' : ''}">
|
|
|
{item.label}
|
|
|
{#each item.voices as voice}
|
|
|
<div class="text-xs">{voice}</div>
|
|
|
{/each}
|
|
|
- {#if i !== dotaVoices.length - 1}
|
|
|
- <div class="h-px mt-1 bg-gray-100 dark:bg-gray-800" />
|
|
|
- {/if}
|
|
|
+ <div class="h-px mt-1 bg-black/10 dark:bg-white/10"></div>
|
|
|
</div>
|
|
|
- </Radio>
|
|
|
- {/each}
|
|
|
- </RadioGroup>
|
|
|
+ </div>
|
|
|
+ {/snippet}
|
|
|
+ </Radio>
|
|
|
</div>
|