webcoreui 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -11
- package/astro.d.ts +31 -11
- package/astro.js +23 -1
- package/components/Alert/Alert.astro +3 -5
- package/components/Alert/Alert.svelte +3 -5
- package/components/Alert/Alert.tsx +3 -3
- package/components/Alert/alert.scss +1 -0
- package/components/Alert/alert.ts +6 -1
- package/components/Avatar/Avatar.astro +51 -0
- package/components/Avatar/Avatar.svelte +48 -0
- package/components/Avatar/Avatar.tsx +64 -0
- package/components/Avatar/avatar.scss +35 -0
- package/components/Avatar/avatar.ts +10 -0
- package/components/Badge/Badge.astro +4 -7
- package/components/Badge/Badge.svelte +2 -5
- package/components/Badge/Badge.tsx +3 -3
- package/components/Badge/badge.ts +4 -1
- package/components/Button/Button.astro +1 -4
- package/components/Button/Button.svelte +1 -4
- package/components/Button/Button.tsx +2 -2
- package/components/Button/button.scss +0 -1
- package/components/Button/button.ts +4 -0
- package/components/Card/Card.astro +2 -5
- package/components/Card/Card.svelte +1 -4
- package/components/Card/Card.tsx +2 -2
- package/components/Card/card.scss +1 -0
- package/components/Card/card.ts +7 -0
- package/components/Checkbox/Checkbox.astro +51 -0
- package/components/Checkbox/Checkbox.svelte +52 -0
- package/components/Checkbox/Checkbox.tsx +65 -0
- package/components/Checkbox/checkbox.scss +85 -0
- package/components/Checkbox/checkbox.ts +12 -0
- package/components/ConditionalWrapper/ConditionalWrapper.tsx +2 -8
- package/components/ConditionalWrapper/conditionalwrapper.ts +5 -0
- package/components/Progress/Progress.astro +40 -0
- package/components/Progress/Progress.svelte +38 -0
- package/components/Progress/Progress.tsx +47 -0
- package/components/Progress/progress.scss +66 -0
- package/components/Progress/progress.ts +12 -0
- package/components/Radio/Radio.astro +57 -0
- package/components/Radio/Radio.svelte +56 -0
- package/components/Radio/Radio.tsx +68 -0
- package/components/Radio/radio.scss +92 -0
- package/components/Radio/radio.ts +17 -0
- package/components/Rating/Rating.astro +66 -0
- package/components/Rating/Rating.svelte +70 -0
- package/components/Rating/Rating.tsx +67 -0
- package/components/Rating/rating.scss +37 -0
- package/components/Rating/rating.ts +16 -0
- package/components/Spinner/Spinner.astro +42 -0
- package/components/Spinner/Spinner.svelte +38 -0
- package/components/Spinner/Spinner.tsx +44 -0
- package/components/Spinner/spinner.scss +41 -0
- package/components/Spinner/spinner.ts +7 -0
- package/components/Switch/Switch.astro +38 -0
- package/components/Switch/Switch.svelte +42 -0
- package/components/Switch/Switch.tsx +46 -0
- package/components/Switch/switch.scss +84 -0
- package/components/Switch/switch.ts +15 -0
- package/components/Tabs/Tabs.astro +76 -0
- package/components/Tabs/Tabs.svelte +54 -0
- package/components/Tabs/Tabs.tsx +69 -0
- package/components/Tabs/tabs.scss +134 -0
- package/components/Tabs/tabs.ts +16 -0
- package/components/Timeline/Timeline.astro +34 -0
- package/components/Timeline/Timeline.svelte +30 -0
- package/components/Timeline/Timeline.tsx +37 -0
- package/components/Timeline/timeline.scss +71 -0
- package/components/Timeline/timeline.ts +61 -0
- package/components/TimelineItem/TimelineItem.astro +26 -0
- package/components/TimelineItem/TimelineItem.svelte +22 -0
- package/components/TimelineItem/TimelineItem.tsx +32 -0
- package/components/TimelineItem/timelineitem.scss +31 -0
- package/components/TimelineItem/timelineitem.ts +5 -0
- package/components/Toast/Toast.astro +30 -0
- package/components/Toast/Toast.svelte +21 -0
- package/components/Toast/Toast.tsx +28 -0
- package/components/Toast/toast.scss +43 -0
- package/components/Toast/toast.ts +11 -0
- package/icons/check.svg +1 -2
- package/icons/circle-check.svg +4 -0
- package/index.js +1 -0
- package/package.json +5 -2
- package/react.d.ts +38 -17
- package/react.js +23 -1
- package/scss/global/tooltip.scss +133 -0
- package/scss/global/utility.scss +17 -0
- package/scss/global.scss +1 -0
- package/scss/resets.scss +4 -0
- package/scss/setup.scss +31 -1
- package/svelte.d.ts +31 -11
- package/svelte.js +23 -1
- package/utils/toast.ts +65 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactRadioProps } from './radio'
|
|
3
|
+
|
|
4
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
5
|
+
|
|
6
|
+
import './radio.scss'
|
|
7
|
+
|
|
8
|
+
const Radio = ({
|
|
9
|
+
name,
|
|
10
|
+
items,
|
|
11
|
+
color,
|
|
12
|
+
inline,
|
|
13
|
+
className,
|
|
14
|
+
onChange
|
|
15
|
+
}: ReactRadioProps) => {
|
|
16
|
+
const classes = [
|
|
17
|
+
'w-radio',
|
|
18
|
+
inline && 'inline',
|
|
19
|
+
className
|
|
20
|
+
].filter(Boolean).join(' ')
|
|
21
|
+
|
|
22
|
+
const style = color
|
|
23
|
+
? { '--w-radio-color': color } as React.CSSProperties
|
|
24
|
+
: undefined
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className={classes} style={style}>
|
|
28
|
+
{items.map((item, index) => (
|
|
29
|
+
<label className={[
|
|
30
|
+
item.subText && 'col',
|
|
31
|
+
item.disabled && 'disabled'
|
|
32
|
+
].filter(Boolean).join(' ')} key={index}>
|
|
33
|
+
<ConditionalWrapper
|
|
34
|
+
condition={!!(item.subText)}
|
|
35
|
+
wrapper={children => (
|
|
36
|
+
<div className="radio-wrapper">
|
|
37
|
+
{children}
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
>
|
|
41
|
+
<input
|
|
42
|
+
type="radio"
|
|
43
|
+
name={name}
|
|
44
|
+
value={item.value}
|
|
45
|
+
defaultChecked={item.selected}
|
|
46
|
+
disabled={item.disabled}
|
|
47
|
+
onChange={onChange}
|
|
48
|
+
/>
|
|
49
|
+
<span className="radio" />
|
|
50
|
+
<span
|
|
51
|
+
className="label"
|
|
52
|
+
dangerouslySetInnerHTML={{ __html: item.label }}
|
|
53
|
+
/>
|
|
54
|
+
</ConditionalWrapper>
|
|
55
|
+
{item.subText && (
|
|
56
|
+
<span
|
|
57
|
+
className="sub-text"
|
|
58
|
+
dangerouslySetInnerHTML={{ __html: item.subText }}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
61
|
+
</label>
|
|
62
|
+
))}
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default Radio
|
|
68
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-radio {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: 10px;
|
|
7
|
+
|
|
8
|
+
&.inline {
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
label {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 5px;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
font-size: 16px;
|
|
18
|
+
|
|
19
|
+
&.disabled {
|
|
20
|
+
cursor: no-drop;
|
|
21
|
+
|
|
22
|
+
input + span::after {
|
|
23
|
+
background: #BBB;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.col {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: flex-start;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
input {
|
|
34
|
+
display: none;
|
|
35
|
+
|
|
36
|
+
+ span::after {
|
|
37
|
+
@include Transition(transform);
|
|
38
|
+
content: '';
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 50%;
|
|
41
|
+
left: 50%;
|
|
42
|
+
transform: translate(-50%, -50%) scale(0);
|
|
43
|
+
width: 8px;
|
|
44
|
+
height: 8px;
|
|
45
|
+
border-radius: 100%;
|
|
46
|
+
background: var(--w-radio-color);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:checked + span::after {
|
|
50
|
+
transform: translate(-50%, -50%) scale(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:disabled + span {
|
|
54
|
+
background-color: #333;
|
|
55
|
+
border-color: #333;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
a {
|
|
60
|
+
text-decoration: underline;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.radio-wrapper {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: 10px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.radio {
|
|
70
|
+
display: inline-block;
|
|
71
|
+
width: 16px;
|
|
72
|
+
height: 16px;
|
|
73
|
+
border-radius: 100%;
|
|
74
|
+
border: 1px solid var(--w-radio-color);
|
|
75
|
+
position: relative;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.sub-text {
|
|
79
|
+
margin-left: 25px;
|
|
80
|
+
font-size: 14px;
|
|
81
|
+
color: #BBB;
|
|
82
|
+
|
|
83
|
+
a {
|
|
84
|
+
@include Transition(color);
|
|
85
|
+
color: #BBB;
|
|
86
|
+
|
|
87
|
+
&:hover {
|
|
88
|
+
color: #FFF;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type RadioProps = {
|
|
2
|
+
items: {
|
|
3
|
+
label: string
|
|
4
|
+
value: string
|
|
5
|
+
subText?: string
|
|
6
|
+
selected?: boolean
|
|
7
|
+
disabled?: boolean
|
|
8
|
+
}[]
|
|
9
|
+
name: string
|
|
10
|
+
color?: string
|
|
11
|
+
inline?: boolean
|
|
12
|
+
className?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ReactRadioProps = {
|
|
16
|
+
onChange?: (key: any) => any
|
|
17
|
+
} & RadioProps
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { RatingProps } from './rating'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.astro'
|
|
4
|
+
|
|
5
|
+
import './rating.scss'
|
|
6
|
+
|
|
7
|
+
interface Props extends RatingProps {}
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
score,
|
|
11
|
+
total = 5,
|
|
12
|
+
showText,
|
|
13
|
+
text = '{0} out of {1}',
|
|
14
|
+
showEmpty = true,
|
|
15
|
+
outline = true,
|
|
16
|
+
reviewCount,
|
|
17
|
+
reviewText = '{0} reviews',
|
|
18
|
+
reviewLink,
|
|
19
|
+
reviewTarget,
|
|
20
|
+
color,
|
|
21
|
+
emptyColor,
|
|
22
|
+
size,
|
|
23
|
+
className
|
|
24
|
+
} = Astro.props
|
|
25
|
+
|
|
26
|
+
const classes = [
|
|
27
|
+
'w-rating',
|
|
28
|
+
outline && 'outline',
|
|
29
|
+
className
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
const styles = [
|
|
33
|
+
color && `--w-rating-color: ${color};`,
|
|
34
|
+
size && `--w-rating-size: ${size}px;`,
|
|
35
|
+
emptyColor && `--w-rating-empty-color: ${emptyColor};`
|
|
36
|
+
].filter(Boolean).join(' ')
|
|
37
|
+
|
|
38
|
+
const translatedText = text
|
|
39
|
+
.replace('{0}', `${score}`)
|
|
40
|
+
.replace('{1}', `${total}`)
|
|
41
|
+
|
|
42
|
+
const translatedReviewText = reviewText.replace('{0}', `${reviewCount}`)
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
<span class:list={classes} style={styles || null}>
|
|
46
|
+
<span class="score">{Array(score).fill('★').join('')}</span>
|
|
47
|
+
{showEmpty && (
|
|
48
|
+
<span class:list={['empty', total === 10 && 'ten-star']}>
|
|
49
|
+
{Array(total - score).fill('★').join('')}
|
|
50
|
+
</span>
|
|
51
|
+
)}
|
|
52
|
+
{showText && (
|
|
53
|
+
<span class:list={['text', reviewCount && 'm']}>
|
|
54
|
+
{translatedText}
|
|
55
|
+
</span>
|
|
56
|
+
)}
|
|
57
|
+
{reviewCount && '•'}
|
|
58
|
+
{reviewCount && (
|
|
59
|
+
<ConditionalWrapper condition={!!reviewLink}>
|
|
60
|
+
<a href={reviewLink} target={reviewTarget} slot="wrapper">
|
|
61
|
+
children
|
|
62
|
+
</a>
|
|
63
|
+
<span class="text">{translatedReviewText}</span>
|
|
64
|
+
</ConditionalWrapper>
|
|
65
|
+
)}
|
|
66
|
+
</span>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { RatingProps } from './rating'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.svelte'
|
|
4
|
+
|
|
5
|
+
import './rating.scss'
|
|
6
|
+
|
|
7
|
+
export let score: RatingProps['score']
|
|
8
|
+
export let total: RatingProps['total'] = 5
|
|
9
|
+
export let showText: RatingProps['showText'] = false
|
|
10
|
+
export let text: RatingProps['text'] = '{0} out of {1}'
|
|
11
|
+
export let showEmpty: RatingProps['showEmpty'] = true
|
|
12
|
+
export let outline: RatingProps['outline'] = true
|
|
13
|
+
export let reviewCount: RatingProps['reviewCount'] = 0
|
|
14
|
+
export let reviewText: RatingProps['reviewText'] = '{0} reviews'
|
|
15
|
+
export let reviewLink: RatingProps['reviewLink'] = ''
|
|
16
|
+
export let reviewTarget: RatingProps['reviewTarget'] = ''
|
|
17
|
+
export let color: RatingProps['color'] = ''
|
|
18
|
+
export let emptyColor: RatingProps['emptyColor'] = ''
|
|
19
|
+
export let size: RatingProps['size'] = 0
|
|
20
|
+
export let className: RatingProps['className'] = ''
|
|
21
|
+
|
|
22
|
+
const classes = [
|
|
23
|
+
'w-rating',
|
|
24
|
+
outline && 'outline',
|
|
25
|
+
className
|
|
26
|
+
].filter(Boolean).join(' ')
|
|
27
|
+
|
|
28
|
+
const styles = [
|
|
29
|
+
color && `--w-rating-color: ${color};`,
|
|
30
|
+
size && `--w-rating-size: ${size}px;`,
|
|
31
|
+
emptyColor && `--w-rating-empty-color: ${emptyColor};`
|
|
32
|
+
].filter(Boolean).join(' ')
|
|
33
|
+
|
|
34
|
+
const translatedText = text!
|
|
35
|
+
.replace('{0}', `${score}`)
|
|
36
|
+
.replace('{1}', `${total}`)
|
|
37
|
+
|
|
38
|
+
const translatedReviewText = reviewText?.replace('{0}', `${reviewCount}`)
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
<span class={classes} style={styles || null}>
|
|
43
|
+
<span class="score">{Array(score).fill('★').join('')}</span>
|
|
44
|
+
{#if showEmpty}
|
|
45
|
+
<span
|
|
46
|
+
class="empty"
|
|
47
|
+
class:ten-star={total === 10}
|
|
48
|
+
>
|
|
49
|
+
{Array((total || 5) - score).fill('★').join('')}
|
|
50
|
+
</span>
|
|
51
|
+
{/if}
|
|
52
|
+
|
|
53
|
+
{#if showText}
|
|
54
|
+
<span class="text" class:m={reviewCount}>
|
|
55
|
+
{translatedText}
|
|
56
|
+
</span>
|
|
57
|
+
{/if}
|
|
58
|
+
|
|
59
|
+
{#if reviewCount}
|
|
60
|
+
{'•'}
|
|
61
|
+
<ConditionalWrapper
|
|
62
|
+
condition={!!reviewLink}
|
|
63
|
+
element="a"
|
|
64
|
+
href={reviewLink}
|
|
65
|
+
target={reviewTarget}
|
|
66
|
+
>
|
|
67
|
+
<span class="text">{translatedReviewText}</span>
|
|
68
|
+
</ConditionalWrapper>
|
|
69
|
+
{/if}
|
|
70
|
+
</span>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { RatingProps } from './rating'
|
|
3
|
+
import ConditionalWrapper from '../ConditionalWrapper/ConditionalWrapper.tsx'
|
|
4
|
+
import './rating.scss'
|
|
5
|
+
|
|
6
|
+
const Rating = ({
|
|
7
|
+
score,
|
|
8
|
+
total = 5,
|
|
9
|
+
showText,
|
|
10
|
+
text = '{0} out of {1}',
|
|
11
|
+
showEmpty = true,
|
|
12
|
+
outline = true,
|
|
13
|
+
reviewCount,
|
|
14
|
+
reviewText = '{0} reviews',
|
|
15
|
+
reviewLink,
|
|
16
|
+
reviewTarget,
|
|
17
|
+
color,
|
|
18
|
+
emptyColor,
|
|
19
|
+
size,
|
|
20
|
+
className
|
|
21
|
+
}: RatingProps) => {
|
|
22
|
+
const classes = [
|
|
23
|
+
'w-rating',
|
|
24
|
+
outline && 'outline',
|
|
25
|
+
className
|
|
26
|
+
].filter(Boolean).join(' ')
|
|
27
|
+
|
|
28
|
+
const styles = {
|
|
29
|
+
...(color && { '--w-rating-color': color }),
|
|
30
|
+
...(size && { '--w-rating-size': `${size}px` }),
|
|
31
|
+
...(emptyColor && { '--w-rating-empty-color': emptyColor })
|
|
32
|
+
} as React.CSSProperties
|
|
33
|
+
|
|
34
|
+
const translatedText = text
|
|
35
|
+
.replace('{0}', `${score}`)
|
|
36
|
+
.replace('{1}', `${total}`)
|
|
37
|
+
|
|
38
|
+
const translatedReviewText = reviewText.replace('{0}', `${reviewCount}`)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<span className={classes} style={styles}>
|
|
42
|
+
<span className="score">{Array(score).fill('★').join('')}</span>
|
|
43
|
+
{showEmpty && (
|
|
44
|
+
<span className={total === 10 ? 'empty ten-star' : 'empty'}>
|
|
45
|
+
{Array(total - score).fill('★').join('')}
|
|
46
|
+
</span>
|
|
47
|
+
)}
|
|
48
|
+
{showText && (
|
|
49
|
+
<span className={reviewCount ? 'text m' : 'text'}>
|
|
50
|
+
{translatedText}
|
|
51
|
+
</span>
|
|
52
|
+
)}
|
|
53
|
+
{reviewCount && '•'}
|
|
54
|
+
{reviewCount && (
|
|
55
|
+
<ConditionalWrapper condition={!!reviewLink} wrapper={children => (
|
|
56
|
+
<a href={reviewLink} target={reviewTarget}>
|
|
57
|
+
{children}
|
|
58
|
+
</a>
|
|
59
|
+
)}>
|
|
60
|
+
<span className="text">{translatedReviewText}</span>
|
|
61
|
+
</ConditionalWrapper>
|
|
62
|
+
)}
|
|
63
|
+
</span>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default Rating
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-rating {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
color: var(--w-rating-color);
|
|
7
|
+
font-size: var(--w-rating-size);
|
|
8
|
+
|
|
9
|
+
&.outline .empty {
|
|
10
|
+
transform: scale(.88);
|
|
11
|
+
color: black;
|
|
12
|
+
text-shadow: -1px 0 var(--w-rating-color), 0 1px var(--w-rating-color), 1px 0 var(--w-rating-color), 0 -1px var(--w-rating-color);
|
|
13
|
+
letter-spacing: 2px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.empty {
|
|
17
|
+
color: var(--w-rating-empty-color);
|
|
18
|
+
|
|
19
|
+
&.ten-star {
|
|
20
|
+
margin-left: -3px;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
a {
|
|
25
|
+
text-decoration: underline;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.text {
|
|
29
|
+
font-size: 16px;
|
|
30
|
+
color: #BBB;
|
|
31
|
+
margin-left: 5px;
|
|
32
|
+
|
|
33
|
+
&.m {
|
|
34
|
+
margin-right: 5px;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type RatingProps = {
|
|
2
|
+
score: number
|
|
3
|
+
total?: number
|
|
4
|
+
showText?: boolean
|
|
5
|
+
text?: string
|
|
6
|
+
showEmpty?: boolean
|
|
7
|
+
outline?: boolean
|
|
8
|
+
reviewCount?: number
|
|
9
|
+
reviewText?: string
|
|
10
|
+
reviewLink?: string
|
|
11
|
+
reviewTarget?: string
|
|
12
|
+
color?: string
|
|
13
|
+
emptyColor?: string
|
|
14
|
+
size?: number
|
|
15
|
+
className?: string
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
import './spinner.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends SpinnerProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
color,
|
|
9
|
+
width,
|
|
10
|
+
speed,
|
|
11
|
+
size,
|
|
12
|
+
dashArray,
|
|
13
|
+
} = Astro.props
|
|
14
|
+
|
|
15
|
+
const classes = [
|
|
16
|
+
'w-spinner',
|
|
17
|
+
dashArray && 'dashed'
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const styles = [
|
|
21
|
+
color && `--w-spinner-color: ${color};`,
|
|
22
|
+
width && `--w-spinner-width: ${width}px;`,
|
|
23
|
+
speed && `--w-spinner-speed: ${speed}s;`,
|
|
24
|
+
size && `--w-spinner-size: ${size}px;`,
|
|
25
|
+
dashArray && `--w-spinner-dash: ${dashArray}`,
|
|
26
|
+
].filter(Boolean).join(' ')
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<svg
|
|
30
|
+
class:list={classes}
|
|
31
|
+
viewBox="25 25 50 50"
|
|
32
|
+
role="status"
|
|
33
|
+
style={styles}
|
|
34
|
+
>
|
|
35
|
+
<circle
|
|
36
|
+
class="spinner-path"
|
|
37
|
+
cx="50"
|
|
38
|
+
cy="50"
|
|
39
|
+
r="20"
|
|
40
|
+
fill="none"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
import './spinner.scss'
|
|
4
|
+
|
|
5
|
+
export let color: SpinnerProps['color'] = ''
|
|
6
|
+
export let width: SpinnerProps['width'] = 0
|
|
7
|
+
export let speed: SpinnerProps['speed'] = 0
|
|
8
|
+
export let size: SpinnerProps['size'] = 0
|
|
9
|
+
export let dashArray: SpinnerProps['dashArray'] = 0
|
|
10
|
+
|
|
11
|
+
const classes = [
|
|
12
|
+
'w-spinner',
|
|
13
|
+
dashArray && 'dashed'
|
|
14
|
+
].filter(Boolean).join(' ')
|
|
15
|
+
|
|
16
|
+
const styles = [
|
|
17
|
+
color && `--w-spinner-color: ${color};`,
|
|
18
|
+
width && `--w-spinner-width: ${width}px;`,
|
|
19
|
+
speed && `--w-spinner-speed: ${speed}s;`,
|
|
20
|
+
size && `--w-spinner-size: ${size}px;`,
|
|
21
|
+
dashArray && `--w-spinner-dash: ${dashArray}`,
|
|
22
|
+
].filter(Boolean).join(' ')
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<svg
|
|
26
|
+
class={classes}
|
|
27
|
+
viewBox="25 25 50 50"
|
|
28
|
+
role="status"
|
|
29
|
+
style={styles}
|
|
30
|
+
>
|
|
31
|
+
<circle
|
|
32
|
+
class="spinner-path"
|
|
33
|
+
cx="50"
|
|
34
|
+
cy="50"
|
|
35
|
+
r="20"
|
|
36
|
+
fill="none"
|
|
37
|
+
/>
|
|
38
|
+
</svg>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { SpinnerProps } from './spinner'
|
|
3
|
+
|
|
4
|
+
import './spinner.scss'
|
|
5
|
+
|
|
6
|
+
const Spinner = ({
|
|
7
|
+
color,
|
|
8
|
+
width,
|
|
9
|
+
speed,
|
|
10
|
+
size,
|
|
11
|
+
dashArray
|
|
12
|
+
}: SpinnerProps) => {
|
|
13
|
+
const classes = [
|
|
14
|
+
'w-spinner',
|
|
15
|
+
dashArray && 'dashed'
|
|
16
|
+
].filter(Boolean).join(' ')
|
|
17
|
+
|
|
18
|
+
const styles = {
|
|
19
|
+
...(color && { '--w-spinner-color': color }),
|
|
20
|
+
...(width && { '--w-spinner-width': `${width}px;` }),
|
|
21
|
+
...(speed && { '--w-spinner-speed': `${speed}s;` }),
|
|
22
|
+
...(size && { '--w-spinner-size': `${size}px;` }),
|
|
23
|
+
...(dashArray && { '--w-spinner-dash': dashArray }),
|
|
24
|
+
} as React.CSSProperties
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<svg
|
|
28
|
+
className={classes}
|
|
29
|
+
viewBox="25 25 50 50"
|
|
30
|
+
role="status"
|
|
31
|
+
style={styles}
|
|
32
|
+
>
|
|
33
|
+
<circle
|
|
34
|
+
className="spinner-path"
|
|
35
|
+
cx="50"
|
|
36
|
+
cy="50"
|
|
37
|
+
r="20"
|
|
38
|
+
fill="none"
|
|
39
|
+
/>
|
|
40
|
+
</svg>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Spinner
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import '../../scss/config.scss';
|
|
2
|
+
|
|
3
|
+
.w-spinner {
|
|
4
|
+
margin: 0px auto;
|
|
5
|
+
width: var(--w-spinner-size);
|
|
6
|
+
height: var(--w-spinner-size);
|
|
7
|
+
animation: rotate var(--w-spinner-speed) linear infinite;
|
|
8
|
+
|
|
9
|
+
&.dashed .spinner-path {
|
|
10
|
+
stroke-dasharray: var(--w-spinner-dash);
|
|
11
|
+
animation: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.spinner-path {
|
|
15
|
+
stroke: var(--w-spinner-color);
|
|
16
|
+
stroke-width: var(--w-spinner-width);
|
|
17
|
+
animation: dash 1.5s ease-in-out infinite;
|
|
18
|
+
stroke-linecap: round;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@keyframes rotate {
|
|
23
|
+
100% {
|
|
24
|
+
transform: rotate(360deg);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes dash {
|
|
29
|
+
0% {
|
|
30
|
+
stroke-dasharray: 1, 200;
|
|
31
|
+
stroke-dashoffset: 0;
|
|
32
|
+
}
|
|
33
|
+
50% {
|
|
34
|
+
stroke-dasharray: 89, 200;
|
|
35
|
+
stroke-dashoffset: -35;
|
|
36
|
+
}
|
|
37
|
+
100% {
|
|
38
|
+
stroke-dasharray: 89, 200;
|
|
39
|
+
stroke-dashoffset: -124;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { SwitchProps } from './switch'
|
|
3
|
+
import './switch.scss'
|
|
4
|
+
|
|
5
|
+
interface Props extends SwitchProps {}
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
label,
|
|
9
|
+
toggled,
|
|
10
|
+
offColor,
|
|
11
|
+
onColor,
|
|
12
|
+
reverse,
|
|
13
|
+
small,
|
|
14
|
+
square,
|
|
15
|
+
disabled,
|
|
16
|
+
className
|
|
17
|
+
} = Astro.props
|
|
18
|
+
|
|
19
|
+
const classes = [
|
|
20
|
+
'w-switch',
|
|
21
|
+
reverse && 'reverse',
|
|
22
|
+
small && 'small',
|
|
23
|
+
square && 'square',
|
|
24
|
+
disabled && 'disabled',
|
|
25
|
+
className
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const styles = [
|
|
29
|
+
offColor && `--w-switch-off-color: ${offColor};`,
|
|
30
|
+
onColor && `--w-switch-on-color: ${onColor};`
|
|
31
|
+
].filter(Boolean).join(' ')
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<label class:list={classes} style={styles || null}>
|
|
35
|
+
<input type="checkbox" checked={toggled} disabled={disabled} />
|
|
36
|
+
<span class="toggle"></span>
|
|
37
|
+
{label && <span class="label">{label}</span>}
|
|
38
|
+
</label>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SwitchProps } from './switch'
|
|
3
|
+
import './switch.scss'
|
|
4
|
+
|
|
5
|
+
export let label: SwitchProps['label'] = ''
|
|
6
|
+
export let toggled: SwitchProps['toggled'] = false
|
|
7
|
+
export let offColor: SwitchProps['offColor'] = ''
|
|
8
|
+
export let onColor: SwitchProps['onColor'] = ''
|
|
9
|
+
export let reverse: SwitchProps['reverse'] = false
|
|
10
|
+
export let small: SwitchProps['small'] = false
|
|
11
|
+
export let square: SwitchProps['square'] = false
|
|
12
|
+
export let disabled: SwitchProps['disabled'] = false
|
|
13
|
+
export let className: SwitchProps['className'] = ''
|
|
14
|
+
export let onClick: () => any = () => {}
|
|
15
|
+
|
|
16
|
+
const classes = [
|
|
17
|
+
'w-switch',
|
|
18
|
+
reverse && 'reverse',
|
|
19
|
+
small && 'small',
|
|
20
|
+
square && 'square',
|
|
21
|
+
disabled && 'disabled',
|
|
22
|
+
className
|
|
23
|
+
].filter(Boolean).join(' ')
|
|
24
|
+
|
|
25
|
+
const styles = [
|
|
26
|
+
offColor && `--w-switch-off-color: ${offColor};`,
|
|
27
|
+
onColor && `--w-switch-on-color: ${onColor};`
|
|
28
|
+
].filter(Boolean).join(' ')
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<label class={classes} style={styles || null}>
|
|
32
|
+
<input
|
|
33
|
+
type="checkbox"
|
|
34
|
+
checked={toggled}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
on:click={onClick}
|
|
37
|
+
/>
|
|
38
|
+
<span class="toggle"></span>
|
|
39
|
+
{#if label}
|
|
40
|
+
<span class="label">{label}</span>
|
|
41
|
+
{/if}
|
|
42
|
+
</label>
|