-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added switch three sizes (#286)
- Loading branch information
Showing
7 changed files
with
138 additions
and
46 deletions.
There are no files selected for viewing
20 changes: 13 additions & 7 deletions
20
components/Switch/__test__/__snapshots__/switch.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Test: KSwitch > props: attrs 1`] = `"<div class=\\"k-switch--base k-switch__un_checked\\" aria-hidden=\\"true\\" you=\\"world\\"><div class=\\"k-switch-tx__un_checked\\"></div> <div class=\\"k-switch-circle\\"></div> </div>"`; | ||
exports[`Test: KSwitch > props: attrs 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked\\" aria-hidden=\\"true\\" you=\\"world\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: cls 1`] = `"<div class=\\"k-switch--base k-switch__un_checked 关关雎鸠,在河之洲\\" aria-hidden=\\"true\\"><div class=\\"k-switch-tx__un_checked\\"></div> <div class=\\"k-switch-circle\\"></div> </div>"`; | ||
exports[`Test: KSwitch > props: cls 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked 关关雎鸠,在河之洲\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: disabled 1`] = `"<div class=\\"k-switch--base k-switch__un_checked\\" aria-hidden=\\"true\\"><div class=\\"k-switch-tx__un_checked\\"></div> <div class=\\"k-switch-circle\\"></div> </div>"`; | ||
exports[`Test: KSwitch > props: disabled 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: loading 1`] = `"<div class=\\"k-switch--base k-switch__un_checked\\" aria-hidden=\\"true\\"><div class=\\"k-switch-tx__un_checked\\"></div> <div class=\\"k-switch-circle\\"></div> </div>"`; | ||
exports[`Test: KSwitch > props: loading 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: unCheckedColor and checkedColor 1`] = `"<div class=\\"k-switch--base k-switch__checked #1314\\" aria-hidden=\\"true\\"> <div class=\\"k-switch-circle\\"></div> <div class=\\"k-switch-tx__checked\\"></div></div>"`; | ||
exports[`Test: KSwitch > props: size 1`] = `"<div class=\\"k-switch k-switch--base k-switch--sm k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--sm\\"></span> <span class=\\"k-switch-circle k-switch-circle--sm\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: unCheckedValue and checkedValue 1`] = `"<div class=\\"k-switch--base k-switch__checked k-switch-tra\\" aria-hidden=\\"true\\"> <div class=\\"k-switch-circle\\" style=\\"right: 1px;\\"></div> <div class=\\"k-switch-tx__checked\\"></div></div>"`; | ||
exports[`Test: KSwitch > props: size 2`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: value 1`] = `"<div class=\\"k-switch--base k-switch__un_checked\\" aria-hidden=\\"true\\"><div class=\\"k-switch-tx__un_checked\\"></div> <div class=\\"k-switch-circle\\"></div> </div>"`; | ||
exports[`Test: KSwitch > props: size 3`] = `"<div class=\\"k-switch k-switch--base k-switch--lg k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--lg\\"></span> <span class=\\"k-switch-circle k-switch-circle--lg\\"></span> </div>"`; | ||
exports[`Test: KSwitch > props: unCheckedColor and checkedColor 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__checked #1314\\" aria-hidden=\\"true\\"> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> <span class=\\"k-switch-tx__checked k-switch-tx__checked--md\\"></span></div>"`; | ||
exports[`Test: KSwitch > props: unCheckedValue and checkedValue 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__checked k-switch-tra\\" aria-hidden=\\"true\\"> <span class=\\"k-switch-circle k-switch-circle--md\\" style=\\"right: 1px;\\"></span> <span class=\\"k-switch-tx__checked k-switch-tx__checked--md\\"></span></div>"`; | ||
exports[`Test: KSwitch > props: value 1`] = `"<div class=\\"k-switch k-switch--base k-switch--md k-switch__unchecked\\" aria-hidden=\\"true\\"><span class=\\"k-switch-tx__unchecked k-switch-tx__unchecked--md\\"></span> <span class=\\"k-switch-circle k-switch-circle--md\\"></span> </div>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
/// <reference types="svelte" /> | ||
import type { ClassValue } from 'clsx'; | ||
import type { IKunSize } from '@ikun-ui/utils'; | ||
|
||
export type SwitchValueType = string | number | boolean; | ||
export type KSwitchProps = { | ||
value: string | number | boolean; | ||
checkedValue: string | number | boolean; | ||
unCheckedValue: string | number | boolean; | ||
checkedColor: string; | ||
unCheckedColor: string; | ||
size: IKunSize; | ||
loading: boolean; | ||
disabled: boolean; | ||
cls: ClassValue; | ||
attrs: Record<string, string>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script> | ||
import { KSwitch } from '@ikun-ui/switch'; | ||
let smValue = false; | ||
let mdValue = false; | ||
let lgValue = false; | ||
</script> | ||
|
||
<div class="fi"> | ||
<KSwitch cls="mx4" size="lg" value={smValue} on:updateValue={(e) => (smValue = e.detail)} /> | ||
<KSwitch cls="mx4" size="md" value={mdValue} on:updateValue={(e) => (mdValue = e.detail)} /> | ||
<KSwitch cls="mx4" size="sm" value={lgValue} on:updateValue={(e) => (lgValue = e.detail)} /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
export const switchShortcuts: Record<string, string> = { | ||
// switch | ||
'k-switch--base': 'rounded-full w-10 h-5 fi pr cursor-pointer', | ||
'k-switch': 'infi pr', | ||
'k-switch--base': 'rounded-full cursor-pointer', | ||
'k-switch__disabled': 'k-cur-disabled', | ||
'k-switch__unchecked': 'ikun:40:bg-ikun-main', | ||
'k-switch__checked': 'bg-ikun-main', | ||
'k-switch__un_checked': 'ikun:40:bg-ikun-main', | ||
'k-switch-tx__un_checked': 'p1 ml-5', | ||
'k-switch-tx__checked': 'p1 mr-5', | ||
'k-switch-loading': 'animate-spin h-4 w-4', | ||
'k-switch-circle': | ||
'h-4.5 w-4.5 shadow rounded-full bg-ikun-white fcc pa right-2px k-switch-transition pl-1px', | ||
'k-switch-tx__unchecked': 'line-height-1', | ||
'k-switch-tx__checked': 'line-height-1', | ||
'k-switch-loading': 'animate-spin', | ||
'k-switch-circle': 'infcc pa right-2px shadow rounded-full bg-ikun-white k-switch-transition', | ||
'k-switch-tra': 'animate-ikun-switching', | ||
|
||
// size | ||
'k-switch--sm': 'h-16px text-12px min-w-30px', | ||
'k-switch--md': 'h-20px text-14px min-w-40px', | ||
'k-switch--lg': 'h-24px text-16px min-w-50px', | ||
'k-switch-circle--sm': 'w-14px h-14px', | ||
'k-switch-circle--md': 'w-18px h-18px', | ||
'k-switch-circle--lg': 'w-22px h-22px', | ||
'k-switch-tx__unchecked--sm': 'ml-16px', | ||
'k-switch-tx__checked--sm': 'ml-2px', | ||
'k-switch-tx__unchecked--md': 'ml-22px', | ||
'k-switch-tx__checked--md': 'ml-3px', | ||
'k-switch-tx__unchecked--lg': 'ml-28px', | ||
'k-switch-tx__checked--lg': 'ml-4px', | ||
|
||
// dark | ||
'k-switch-loading__dark': 'dark:text-ikun-tx-base' | ||
}; |