|
1 | 1 | <script lang="ts"> |
2 | | - import Icon from './Icon.svelte'; |
3 | | - import { createEventDispatcher } from 'svelte'; |
| 2 | + import Icon from './Icon.svelte' |
| 3 | + import { createEventDispatcher } from 'svelte' |
4 | 4 |
|
5 | | - const dispatch = createEventDispatcher(); |
| 5 | + const dispatch = createEventDispatcher() |
6 | 6 |
|
7 | | - function handleClick() { |
8 | | - dispatch('click'); |
9 | | - } |
| 7 | + function handleClick() { |
| 8 | + dispatch('click') |
| 9 | + } |
10 | 10 |
|
11 | | - type CircleSize = 'sm' | 'lg' | 'xl' | 'n'; |
12 | | - type CircleColor = 'primary' | 'danger' | 'success' | 'error' | 'warning'; |
| 11 | + type CircleSize = 'sm' | 'lg' | 'xl' | 'n' |
| 12 | + type CircleColor = 'primary' | 'danger' | 'success' | 'error' | 'warning' |
13 | 13 |
|
14 | | - export let icon = 'edit'; |
15 | | - export let size: CircleSize = 'sm'; |
16 | | - export let color: CircleColor = 'primary'; |
17 | | -
|
18 | | - $: btnSize = |
19 | | - size == 'xl' |
20 | | - ? 'w-12 h-12 text-3xl' |
21 | | - : size == 'lg' |
22 | | - ? 'w-10 h-10 text-2xl' |
23 | | - : size == 'sm' |
24 | | - ? 'w-6 h-6 text-base' |
25 | | - : 'w-8 h-8 text-xl'; |
26 | | -
|
27 | | - $: btnColor = |
28 | | - color == 'primary' |
29 | | - ? 'blue' |
30 | | - : color == 'success' |
31 | | - ? 'green' |
32 | | - : color == 'warning' |
33 | | - ? 'yellow' |
34 | | - : 'red'; |
| 14 | + export let icon = 'edit' |
| 15 | + export let size: CircleSize = 'sm' |
| 16 | + export let color: CircleColor = 'primary' |
35 | 17 | </script> |
36 | 18 |
|
37 | 19 | <button |
38 | | - type="button" |
39 | | - class="{btnSize} rounded-full bg-{btnColor}-500 hover:bg-{btnColor}-600 focus:bg-{btnColor}-700 text-white flex flex-col items-center justify-center" |
40 | | - on:click={handleClick} |
41 | | - {...$$props} |
| 20 | + type="button" |
| 21 | + class="circle-{size} rounded-full circle-{color} text-white flex flex-col items-center justify-center" |
| 22 | + on:click={handleClick} |
| 23 | + {...$$props} |
42 | 24 | > |
43 | | - <Icon name={icon} /> |
| 25 | + <Icon name={icon} /> |
44 | 26 | </button> |
| 27 | + |
| 28 | +<style lang="css"> |
| 29 | + button.circle-primary { |
| 30 | + @apply bg-primary-500 hover:bg-primary-600 focus:bg-primary-700; |
| 31 | + } |
| 32 | + button.circle-success { |
| 33 | + @apply bg-green-500 hover:bg-green-600 focus:bg-green-700; |
| 34 | + } |
| 35 | + button.circle-warning { |
| 36 | + @apply bg-yellow-500 hover:bg-yellow-600 focus:bg-yellow-700; |
| 37 | + } |
| 38 | + button.circle-error, |
| 39 | + button.circle-danger { |
| 40 | + @apply bg-red-500 hover:bg-red-600 focus:bg-red-700; |
| 41 | + } |
| 42 | + button.circle-xl { |
| 43 | + @apply w-12 h-12 text-3xl; |
| 44 | + } |
| 45 | + button.circle-lg { |
| 46 | + @apply w-10 h-10 text-2xl; |
| 47 | + } |
| 48 | + button.circle-sm { |
| 49 | + @apply w-6 h-6 text-base; |
| 50 | + } |
| 51 | + button.circle-n { |
| 52 | + @apply w-8 h-8 text-xl; |
| 53 | + } |
| 54 | +</style> |
0 commit comments