webcoreui 0.0.12 → 0.2.0

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.
Files changed (83) hide show
  1. package/README.md +39 -6
  2. package/astro.d.ts +4 -0
  3. package/astro.js +4 -0
  4. package/components/Accordion/accordion.module.scss +20 -27
  5. package/components/Alert/alert.module.scss +19 -22
  6. package/components/Avatar/avatar.module.scss +9 -6
  7. package/components/Badge/badge.module.scss +31 -34
  8. package/components/Button/Button.astro +0 -2
  9. package/components/Button/Button.svelte +0 -2
  10. package/components/Button/Button.tsx +0 -2
  11. package/components/Button/button.module.scss +32 -39
  12. package/components/Button/button.ts +1 -2
  13. package/components/Card/card.module.scss +19 -15
  14. package/components/Checkbox/checkbox.module.scss +27 -41
  15. package/components/Icon/Icon.astro +2 -2
  16. package/components/Icon/map.ts +2 -0
  17. package/components/Input/input.module.scss +28 -36
  18. package/components/Menu/Menu.astro +7 -3
  19. package/components/Menu/Menu.svelte +11 -3
  20. package/components/Menu/Menu.tsx +7 -1
  21. package/components/Menu/menu.module.scss +144 -144
  22. package/components/Menu/menu.ts +1 -0
  23. package/components/Modal/Modal.astro +70 -0
  24. package/components/Modal/Modal.svelte +71 -0
  25. package/components/Modal/Modal.tsx +76 -0
  26. package/components/Modal/modal.module.scss +103 -0
  27. package/components/Modal/modal.ts +18 -0
  28. package/components/Progress/progress.module.scss +26 -22
  29. package/components/Radio/radio.module.scss +32 -41
  30. package/components/Rating/Rating.astro +2 -2
  31. package/components/Rating/Rating.svelte +2 -2
  32. package/components/Rating/Rating.tsx +2 -2
  33. package/components/Rating/rating.module.scss +15 -8
  34. package/components/Slider/Slider.astro +44 -0
  35. package/components/Slider/Slider.svelte +42 -0
  36. package/components/Slider/Slider.tsx +48 -0
  37. package/components/Slider/slider.module.scss +68 -0
  38. package/components/Slider/slider.ts +20 -0
  39. package/components/Spinner/spinner.module.scss +11 -2
  40. package/components/Switch/switch.module.scss +28 -30
  41. package/components/Table/Table.astro +6 -1
  42. package/components/Table/Table.svelte +3 -1
  43. package/components/Table/Table.tsx +7 -1
  44. package/components/Table/table.module.scss +23 -17
  45. package/components/Table/table.ts +1 -0
  46. package/components/Tabs/Tabs.astro +0 -1
  47. package/components/Tabs/tabs.module.scss +45 -48
  48. package/components/ThemeSwitcher/ThemeSwitcher.astro +1 -0
  49. package/components/ThemeSwitcher/ThemeSwitcher.svelte +2 -1
  50. package/components/ThemeSwitcher/ThemeSwitcher.tsx +2 -1
  51. package/components/ThemeSwitcher/themeswitcher.module.scss +28 -26
  52. package/components/Timeline/timeline.module.scss +28 -23
  53. package/components/TimelineItem/TimelineItem.tsx +1 -6
  54. package/components/TimelineItem/timelineitem.module.scss +14 -17
  55. package/components/TimelineItem/timelineitem.ts +5 -0
  56. package/components/Toast/toast.module.scss +10 -14
  57. package/components/Toast/toast.ts +6 -1
  58. package/icons/close.svg +3 -0
  59. package/icons.d.ts +12 -0
  60. package/icons.js +10 -0
  61. package/index.js +2 -0
  62. package/package.json +3 -1
  63. package/react.d.ts +6 -2
  64. package/react.js +4 -0
  65. package/scss/config/color-palette.scss +24 -0
  66. package/scss/config/css-values.scss +44 -0
  67. package/scss/config/layout.scss +41 -0
  68. package/scss/config/mixins.scss +392 -9
  69. package/scss/config/typography.scss +65 -0
  70. package/scss/config.scss +6 -1
  71. package/scss/global/elements.scss +21 -1
  72. package/scss/global/scrollbar.scss +12 -9
  73. package/scss/global/theme.scss +73 -40
  74. package/scss/global/tooltip.scss +42 -35
  75. package/scss/global/utility.scss +79 -61
  76. package/scss/global.scss +0 -1
  77. package/scss/resets.scss +67 -9
  78. package/scss/setup.scss +14 -41
  79. package/svelte.d.ts +4 -0
  80. package/svelte.js +4 -0
  81. package/utils/interpolate.ts +23 -0
  82. package/utils/modal.ts +59 -0
  83. package/utils/toast.ts +3 -2
package/scss/resets.scss CHANGED
@@ -1,4 +1,6 @@
1
- @mixin Resets() {
1
+ @use './config.scss' as *;
2
+
3
+ @mixin resets() {
2
4
  @if (config('fontRegular')) {
3
5
  @font-face {
4
6
  font-family: Regular;
@@ -18,12 +20,12 @@
18
20
  * {
19
21
  box-sizing: border-box;
20
22
  }
21
-
23
+
22
24
  body {
23
- background: var(--w-color-primary-70);
24
- color: var(--w-color-primary);
25
- margin: 0;
26
- font-size: 18px;
25
+ @include background(primary-70);
26
+ @include typography(primary, default);
27
+ @include spacing(m0);
28
+
27
29
  font-family: Regular, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
28
30
  }
29
31
 
@@ -33,16 +35,72 @@
33
35
  h4,
34
36
  h5,
35
37
  h6,
36
- strong {
38
+ strong,
39
+ b {
37
40
  font-family: Bold, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
38
41
  }
39
42
 
40
43
  a {
41
- color: var(--w-color-primary);
42
- text-decoration: none;
44
+ @include transition(color);
45
+ @include typography(primary);
43
46
  }
44
47
 
45
48
  button {
46
49
  font-family: Regular;
47
50
  }
51
+
52
+ code,
53
+ pre {
54
+ @include border(primary-50);
55
+ @include border-radius(md);
56
+ @include typography(md);
57
+ }
58
+
59
+ code {
60
+ @include spacing(px-sm);
61
+ display: inline-block;
62
+ }
63
+
64
+ pre {
65
+ @include background(primary-60);
66
+ @include spacing(p-sm, my-default);
67
+
68
+ }
69
+
70
+ figure {
71
+ @include spacing(my-default);
72
+ @include layout(inline-flex, column, v-center, xs);
73
+ }
74
+
75
+ figcaption {
76
+ @include typography(md, primary-20);
77
+
78
+ a {
79
+ @include typography(primary-20);
80
+
81
+ &:hover {
82
+ @include typography(primary);
83
+ }
84
+ }
85
+ }
86
+
87
+ p, ul, ol {
88
+ @include typography(hlg);
89
+ @include spacing(my-default);
90
+ }
91
+
92
+ li {
93
+ @include spacing(mb-sm);
94
+ }
95
+
96
+ blockquote {
97
+ @include spacing(my-default, mx-none, pl-default);
98
+ @include border(2px, left, primary-30);
99
+ }
100
+
101
+ hr {
102
+ @include size('w100%', h1px);
103
+ @include border(0);
104
+ @include background(primary-50);
105
+ }
48
106
  }
package/scss/setup.scss CHANGED
@@ -2,77 +2,50 @@
2
2
 
3
3
  $config: (
4
4
  includeResets: true,
5
- includeHelperClasses: true,
6
- includeElementStyles: true,
5
+ includeUtilities: true,
7
6
  includeTooltip: true,
8
7
  includeScrollbarStyles: true
9
8
  );
10
9
 
11
10
  body {
12
- --w-avatar-border: var(--w-color-primary-70);
13
- --w-checkbox-color: var(--w-color-primary);
14
- --w-progress-color: var(--w-color-primary);
15
- --w-progress-background: var(--w-color-primary-50);
16
- --w-progress-stripe-light: var(--w-color-primary);
17
- --w-progress-stripe-dark: var(--w-color-primary-10);
18
- --w-radio-color: var(--w-color-primary);
19
- --w-rating-color: var(--w-color-primary);
20
- --w-rating-empty-color: var(--w-color-primary);
21
- --w-rating-empty-background: var(--w-color-primary-70);
22
- --w-rating-size: 18px;
23
- --w-scrollbar-bg: var(--w-color-primary-60);
24
- --w-scrollbar-fg: var(--w-color-primary-50);
25
- --w-spinner-color: var(--w-color-primary);
26
- --w-spinner-width: 2px;
27
- --w-spinner-speed: 2s;
28
- --w-spinner-size: 30px;
29
- --w-spinner-dash: 8;
30
- --w-switch-off-color: var(--w-color-primary-50);
31
- --w-switch-on-color: var(--w-color-primary);
32
- --w-theme-switcher-size: 20px;
33
- --w-timeline-color: var(--w-color-primary-50);
34
- --w-timeline-text-color: var(--w-color-primary);
35
- --w-timeline-counter: decimal;
36
- --w-tooltip-background: var(--w-color-primary);
37
- --w-tooltip-color: var(--w-color-primary-70);
11
+ --w-sm-radius: 2px;
12
+ --w-md-radius: 5px;
13
+ --w-lg-radius: 10px;
14
+ --w-xl-radius: 15px;
38
15
  }
39
16
 
40
17
  @function config($key) {
41
18
  @return map.get($config, $key);
42
19
  }
43
20
 
44
- @mixin Setup($customConfig: ()) {
21
+ @mixin setup($customConfig: ()) {
45
22
  $config: map.merge($config, $customConfig) !global;
46
23
 
47
24
  @if (config('includeResets')) {
48
- @include Resets();
25
+ @include resets();
49
26
  }
50
27
 
51
- @if (config('includeHelperClasses')) {
52
- @include Utility();
53
- }
54
-
55
- @if (config('includeElementStyles')) {
56
- @include Elements();
28
+ @if (config('includeUtilities')) {
29
+ @include utility();
57
30
  }
58
31
 
59
32
  @if (config('includeScrollbarStyles')) {
60
- @include Scrollbar();
33
+ @include scrollbar();
61
34
  }
62
35
 
63
36
  @if (config('includeTooltip')) {
64
- @include Tooltip();
37
+ @include tooltip();
65
38
  }
66
39
 
67
40
  @if (config('theme')) {
68
- @include Theme(config('theme'));
41
+ @include theme(config('theme'));
69
42
  }
70
43
 
71
44
  @if (config('themes')) {
72
45
  @each $theme, $selector in config('themes') {
73
- @include Theme($theme, $selector);
46
+ @include theme($theme, $selector);
74
47
  }
75
48
  } @else if (not config('theme')) {
76
- @include Theme('dark');
49
+ @include theme('dark');
77
50
  }
78
51
  }
package/svelte.d.ts CHANGED
@@ -9,9 +9,11 @@ import type { ConditionalWrapperProps } from './components/ConditionalWrapper/co
9
9
  import type { IconProps } from './components/Icon/icon'
10
10
  import type { SvelteInputProps } from './components/Input/input'
11
11
  import type { MenuProps } from './components/Menu/menu'
12
+ import type { ModalProps } from './components/Modal/modal'
12
13
  import type { ProgressProps } from './components/Progress/progress'
13
14
  import type { SvelteRadioProps } from './components/Radio/radio'
14
15
  import type { RatingProps } from './components/Rating/rating'
16
+ import type { SvelteSliderProps } from './components/Slider/slider'
15
17
  import type { SpinnerProps } from './components/Spinner/spinner'
16
18
  import type { SvelteSwitchProps } from './components/Switch/switch'
17
19
  import type { TableProps } from './components/Table/table'
@@ -33,9 +35,11 @@ declare module 'webcoreui/svelte' {
33
35
  export function Icon(_props: IconProps): any
34
36
  export function Input(_props: SvelteInputProps): any
35
37
  export function Menu(_props: MenuProps): any
38
+ export function Modal(_props: ModalProps): any
36
39
  export function Progress(_props: ProgressProps): any
37
40
  export function Radio(_props: SvelteRadioProps): any
38
41
  export function Rating(_props: RatingProps): any
42
+ export function Slider(_props: SvelteSliderProps): any
39
43
  export function Spinner(_props: SpinnerProps): any
40
44
  export function Switch(_props: SvelteSwitchProps): any
41
45
  export function Table(_props: TableProps): any
package/svelte.js CHANGED
@@ -9,9 +9,11 @@ import ConditionalWrapperComponent from './components/ConditionalWrapper/Conditi
9
9
  import IconComponent from './components/Icon/Icon.svelte'
10
10
  import InputComponent from './components/Input/Input.svelte'
11
11
  import MenuComponent from './components/Menu/Menu.svelte'
12
+ import ModalComponent from './components/Modal/Modal.svelte'
12
13
  import ProgressComponent from './components/Progress/Progress.svelte'
13
14
  import RadioComponent from './components/Radio/Radio.svelte'
14
15
  import RatingComponent from './components/Rating/Rating.svelte'
16
+ import SliderComponent from './components/Slider/Slider.svelte'
15
17
  import SpinnerComponent from './components/Spinner/Spinner.svelte'
16
18
  import SwitchComponent from './components/Switch/Switch.svelte'
17
19
  import TableComponent from './components/Table/Table.svelte'
@@ -32,9 +34,11 @@ export const ConditionalWrapper = ConditionalWrapperComponent
32
34
  export const Icon = IconComponent
33
35
  export const Input = InputComponent
34
36
  export const Menu = MenuComponent
37
+ export const Modal = ModalComponent
35
38
  export const Progress = ProgressComponent
36
39
  export const Radio = RadioComponent
37
40
  export const Rating = RatingComponent
41
+ export const Slider = SliderComponent
38
42
  export const Spinner = SpinnerComponent
39
43
  export const Switch = SwitchComponent
40
44
  export const Table = TableComponent
@@ -0,0 +1,23 @@
1
+ export const clamp = (
2
+ num: number,
3
+ min: number,
4
+ max: number
5
+ ) => Math.min(Math.max(num, min), max)
6
+
7
+ export const lerp = (
8
+ x: number,
9
+ y: number,
10
+ z: number
11
+ ) => x * (1 - z) + y * z
12
+
13
+ export const invlerp = (
14
+ x: number,
15
+ y: number,
16
+ z: number
17
+ ) => clamp((z - x) / (y - x), 0, 1)
18
+
19
+ export const interpolate = (
20
+ value: number,
21
+ input: [x: number, y: number],
22
+ output: [x: number, y: number],
23
+ ) => lerp(output[0], output[1], invlerp(input[0], input[1], value))
package/utils/modal.ts ADDED
@@ -0,0 +1,59 @@
1
+ export const modal = (element: string) => {
2
+ const htmlElement = document.querySelector(element) as HTMLElement
3
+
4
+ if (htmlElement) {
5
+ const handleClose = {
6
+ icon: () => {
7
+ const close = htmlElement.querySelector('[data-id="close"]')
8
+
9
+ const listener = () => {
10
+ htmlElement.dataset.show = ''
11
+
12
+ close?.removeEventListener('click', listener)
13
+ }
14
+
15
+ close?.addEventListener('click', listener)
16
+ },
17
+
18
+ esc: () => {
19
+ const listener = (event: KeyboardEvent) => {
20
+ if (event.key === 'Escape') {
21
+ htmlElement.dataset.show = ''
22
+
23
+ document.removeEventListener('keydown', listener)
24
+ }
25
+ }
26
+
27
+ document.addEventListener('keydown', listener)
28
+ },
29
+
30
+ overlay: () => {
31
+ const close = htmlElement.nextElementSibling
32
+
33
+ const listener = () => {
34
+ htmlElement.dataset.show = ''
35
+
36
+ close?.removeEventListener('click', listener)
37
+ }
38
+
39
+ close?.addEventListener('click', listener)
40
+ }
41
+ }
42
+
43
+ const closeOptions = htmlElement.dataset.close?.split(',')
44
+
45
+ htmlElement.dataset.show = 'true'
46
+
47
+ closeOptions?.forEach(option => {
48
+ handleClose[option as keyof typeof handleClose]()
49
+ })
50
+ }
51
+ }
52
+
53
+ export const closeModal = (element: string) => {
54
+ const htmlElement = document.querySelector(element) as HTMLElement
55
+
56
+ if (htmlElement) {
57
+ htmlElement.dataset.show = ''
58
+ }
59
+ }
package/utils/toast.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AlertProps } from '../components/Alert/alert'
2
+ import type { ToastProps } from '../components/Toast/toast'
2
3
 
3
4
  type Toast = {
4
5
  element: string
@@ -6,12 +7,12 @@ type Toast = {
6
7
  title?: AlertProps['title']
7
8
  content?: string
8
9
  theme?: AlertProps['theme']
9
- position?: string
10
+ position?: ToastProps['position']
10
11
  }
11
12
 
12
13
  let defaultTimeout = 5000
13
14
 
14
- export let setDefaultTimeout = (time: number) => defaultTimeout = time
15
+ export const setDefaultTimeout = (time: number) => defaultTimeout = time
15
16
 
16
17
  export const toast = (config: Toast | string) => {
17
18
  const element = typeof config === 'string'