From c19ddedda6a5cd81c3869be9756bcbf25b102b65 Mon Sep 17 00:00:00 2001 From: Craig Howell Date: Thu, 6 Oct 2022 16:41:02 -0400 Subject: [PATCH] fix(Button): fixed default loading jank fix(Loader): stroke is now currentColor docs(button): added examples, props, and slots tables --- src/lib/components/button-group/Button.svelte | 7 +- src/lib/components/button-group/Loader.svelte | 17 +- src/lib/components/button/Button.svelte | 90 +++++---- src/lib/components/button/Loader.svelte | 17 +- src/routes/button/+page.svelte | 82 +++++++- src/routes/button/examples.ts | 188 ++++++++++++++++++ 6 files changed, 333 insertions(+), 68 deletions(-) create mode 100644 src/routes/button/examples.ts diff --git a/src/lib/components/button-group/Button.svelte b/src/lib/components/button-group/Button.svelte index 25f24672..08e72023 100644 --- a/src/lib/components/button-group/Button.svelte +++ b/src/lib/components/button-group/Button.svelte @@ -20,7 +20,6 @@ export let active = false; export let loading = false; export let defaultLoading = true; - export let buttonLoaderColor = '#ffffff'; export let disabled = false; useContext({ @@ -66,7 +65,7 @@ - + @@ -79,7 +78,7 @@ - + @@ -87,7 +86,7 @@ {:else if loading && defaultLoading && !$$slots.leading && !$$slots.icon}
- +
diff --git a/src/lib/components/button-group/Loader.svelte b/src/lib/components/button-group/Loader.svelte index c06033d0..f34a7c74 100644 --- a/src/lib/components/button-group/Loader.svelte +++ b/src/lib/components/button-group/Loader.svelte @@ -1,14 +1,13 @@ - - - + + +
- - - - - - - - -
- - - {:else if defaultLoading && $$slots.icon} -
- - - - - - - - -
- - - {:else if loading && defaultLoading && !$$slots.leading && !$$slots.icon} -
- -
+ {#if defaultLoading} + {#if $$slots.leading && $$slots.icon} +
+ + + + + + + + +
+
+ + + + + + + + +
+ {:else if $$slots.leading} +
+ + + + + + + + +
+ {:else if $$slots.icon} +
+ + + + + + + + +
+ {:else if loading} +
+ +
+ {/if} {:else} diff --git a/src/lib/components/button/Loader.svelte b/src/lib/components/button/Loader.svelte index c06033d0..f34a7c74 100644 --- a/src/lib/components/button/Loader.svelte +++ b/src/lib/components/button/Loader.svelte @@ -1,14 +1,13 @@ - - - + + +
+
+ + @@ -42,6 +57,11 @@ + +
+
+ + @@ -59,6 +79,11 @@ + +
+
+ + @@ -100,6 +125,11 @@ + +
+
+ + @@ -119,6 +149,11 @@ + +
+
+ + @@ -141,8 +176,13 @@ - I am primary + I am primary + + +
+
+ + @@ -214,3 +254,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/routes/button/examples.ts b/src/routes/button/examples.ts new file mode 100644 index 00000000..2e205eb0 --- /dev/null +++ b/src/routes/button/examples.ts @@ -0,0 +1,188 @@ +import type { Slot, Prop } from '../../docs'; + +export const props: Prop[] = [ + { + id: '1', + prop: 'disabled', + type: 'boolean', + default: 'false' + }, + { + id: '2', + prop: 'htmlType', + type: "'button' | 'submit' | 'reset'", + default: 'button' + }, + { + id: '3', + prop: 'loading', + type: 'boolean', + default: 'false' + }, + { + id: '4', + prop: 'defaultLoading', + type: 'boolean', + default: 'true' + }, + { + id: '5', + prop: 'type', + type: "'default'| 'primary' | 'danger' | 'ghost' | 'link' | 'text' | 'dark' | undefined", + default: '' + }, + { + id: '6', + prop: 'shape', + type: "'square' | 'circle' | 'rounded' | 'pill'", + default: 'rounded' + }, + { + id: '7', + prop: 'size', + type: "'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'fab'", + default: 'md' + } +]; + +export const slots: Slot[] = [ + { + id: '1', + slot: 'leading', + component: '' + }, + { + id: '2', + slot: 'icon', + component: '' + }, + { + id: '3', + slot: 'default', + component: '' + }, + { + id: '4', + slot: 'trailing', + component: '' + } +]; + +export const leadingTrailingIconSlots: Slot[] = [ + { + id: '1', + slot: 'icon', + component: '' + }, + { + id: '2', + slot: 'default', + component: '' + } +]; + +export const iconProps: Prop[] = [ + { + id: '1', + prop: 'icon', + type: 'MaterialIcon (string)', + default: '' + } +]; + +export const exampleDefault = ` + + + + + + +`; + +export const exampleLoading = ` + + + + + + +`; + +export const exampleDisabled = ` + + + + + + +`; + +export const exampleLeadingTrailing = ` + + + + +`; + +export const exampleShape = ` + + + + + + + + + + +`; + +export const exampleSwap = ` + + + + +`;