@rocketui/vue 0.0.47 → 0.0.49

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 (169) hide show
  1. package/dist/rocket-ui-vue.cjs.js +1 -0
  2. package/dist/rocket-ui-vue.d.ts +1812 -0
  3. package/dist/rocket-ui-vue.es.js +9270 -0
  4. package/dist/rocket-ui-vue.umd.js +1 -0
  5. package/dist/style.css +2 -0
  6. package/package.json +7 -1
  7. package/.eslintrc.cjs +0 -79
  8. package/.gitattributes +0 -2
  9. package/.github/workflows/chromatic.yml +0 -28
  10. package/.github/workflows/publish-storybook.yml +0 -41
  11. package/.husky/pre-commit +0 -4
  12. package/.prettierrc.cjs +0 -10
  13. package/.storybook/Theme.js +0 -17
  14. package/.storybook/main.ts +0 -20
  15. package/.storybook/manager-head.html +0 -3
  16. package/.storybook/manager.js +0 -8
  17. package/.storybook/preview-head.html +0 -3
  18. package/.storybook/preview.ts +0 -36
  19. package/.storybook/source-panel/manager.js +0 -28
  20. package/.storybook/withSource.js +0 -91
  21. package/.vscode/extensions.json +0 -11
  22. package/.vscode/settings.json +0 -20
  23. package/index.html +0 -13
  24. package/lib/main.ts +0 -48
  25. package/postcss.config.cjs +0 -9
  26. package/resources/rocket-ui-logo-dark.svg +0 -27
  27. package/resources/rocket-ui-logo-light.svg +0 -27
  28. package/shims-rocketui.d.ts +0 -9
  29. package/src/App.vue +0 -15
  30. package/src/assets/blank-avatar.svg +0 -3
  31. package/src/assets/icons/mdi.js +0 -7302
  32. package/src/assets/logo.svg +0 -1
  33. package/src/components/Accordion/Accordion.mdx +0 -88
  34. package/src/components/Accordion/Accordion.stories.ts +0 -257
  35. package/src/components/Accordion/RAccordion.vue +0 -73
  36. package/src/components/Accordion/accordion.css +0 -75
  37. package/src/components/Accordion/accordion.spec.ts +0 -123
  38. package/src/components/Alert/Alert.mdx +0 -120
  39. package/src/components/Alert/Alert.stories.ts +0 -118
  40. package/src/components/Alert/RAlert.vue +0 -119
  41. package/src/components/Alert/alert.css +0 -136
  42. package/src/components/Alert/alert.spec.ts +0 -32
  43. package/src/components/Avatar/Avatar.mdx +0 -96
  44. package/src/components/Avatar/Avatar.stories.ts +0 -65
  45. package/src/components/Avatar/RAvatar.vue +0 -115
  46. package/src/components/Avatar/avatar.css +0 -82
  47. package/src/components/Avatar/avatar.spec.ts +0 -38
  48. package/src/components/Badge/Badge.mdx +0 -112
  49. package/src/components/Badge/Badge.stories.ts +0 -99
  50. package/src/components/Badge/RBadge.vue +0 -89
  51. package/src/components/Badge/badge.css +0 -63
  52. package/src/components/Badge/badge.spec.ts +0 -20
  53. package/src/components/Box/Box.mdx +0 -20
  54. package/src/components/Box/Box.stories.ts +0 -56
  55. package/src/components/Box/RBox.vue +0 -97
  56. package/src/components/Breadcrumb/Breadcrumb.stories.ts +0 -115
  57. package/src/components/Breadcrumb/RBreadcrumb.vue +0 -43
  58. package/src/components/Breadcrumb/breadcrumb.css +0 -29
  59. package/src/components/Button/Button.mdx +0 -148
  60. package/src/components/Button/Button.spec.ts +0 -29
  61. package/src/components/Button/Button.stories.ts +0 -118
  62. package/src/components/Button/RButton.vue +0 -179
  63. package/src/components/Button/button.css +0 -146
  64. package/src/components/Checkbox/Checkbox.mdx +0 -100
  65. package/src/components/Checkbox/Checkbox.stories.ts +0 -67
  66. package/src/components/Checkbox/RCheckbox.vue +0 -195
  67. package/src/components/Checkbox/checkbox.css +0 -67
  68. package/src/components/Checkbox/checkbox.spec.ts +0 -60
  69. package/src/components/Chips/Chip.mdx +0 -113
  70. package/src/components/Chips/Chip.stories.ts +0 -122
  71. package/src/components/Chips/RChip.vue +0 -125
  72. package/src/components/Chips/chip.css +0 -62
  73. package/src/components/Chips/chip.spec.ts +0 -40
  74. package/src/components/Dropdown/Dropdown.mdx +0 -135
  75. package/src/components/Dropdown/Dropdown.stories.ts +0 -84
  76. package/src/components/Dropdown/RDropdown.vue +0 -392
  77. package/src/components/Dropdown/dropdown.css +0 -113
  78. package/src/components/Dropdown/dropdown.spec.ts +0 -98
  79. package/src/components/Flex/Flex.mdx +0 -20
  80. package/src/components/Flex/Flex.stories.js +0 -127
  81. package/src/components/Flex/RFlex.vue +0 -91
  82. package/src/components/Grid/Grid.mdx +0 -20
  83. package/src/components/Grid/Grid.stories.js +0 -107
  84. package/src/components/Grid/RGrid.vue +0 -138
  85. package/src/components/Icon/Icon.mdx +0 -68
  86. package/src/components/Icon/Icon.stories.ts +0 -33
  87. package/src/components/Icon/RIcon.vue +0 -56
  88. package/src/components/Icon/icon.spec.ts +0 -25
  89. package/src/components/ItemGroup/ItemGroup.stories.ts +0 -91
  90. package/src/components/ItemGroup/RItem.vue +0 -74
  91. package/src/components/ItemGroup/RItemGroup.vue +0 -122
  92. package/src/components/ItemGroup/__snapshots__/itemgroup.spec.ts.snap +0 -13
  93. package/src/components/ItemGroup/itemgroup.spec.ts +0 -67
  94. package/src/components/Label/Label.mdx +0 -50
  95. package/src/components/Label/Label.stories.ts +0 -38
  96. package/src/components/Label/RLabel.vue +0 -42
  97. package/src/components/Label/label.css +0 -0
  98. package/src/components/Modal/Modal.mdx +0 -91
  99. package/src/components/Modal/Modal.stories.ts +0 -125
  100. package/src/components/Modal/RModal.vue +0 -130
  101. package/src/components/Modal/modal.css +0 -41
  102. package/src/components/Modal/modal.spec.ts +0 -25
  103. package/src/components/Pagination/Pagination.stories.ts +0 -24
  104. package/src/components/Pagination/RPagination.vue +0 -103
  105. package/src/components/Pagination/pagination.css +0 -47
  106. package/src/components/Pagination/pagination.spec.ts +0 -17
  107. package/src/components/ProgressBar/ProgressBar.stories.ts +0 -34
  108. package/src/components/ProgressBar/RProgressBar.vue +0 -21
  109. package/src/components/ProgressBar/progressbar.css +0 -24
  110. package/src/components/ProgressBar/progressbar.spec.ts +0 -17
  111. package/src/components/Shared/Enums.ts +0 -1
  112. package/src/components/Sidebar/RSidebar.vue +0 -27
  113. package/src/components/Sidebar/Sidebar.mdx +0 -31
  114. package/src/components/Sidebar/Sidebar.stories.ts +0 -34
  115. package/src/components/Sidebar/sidebar.css +0 -18
  116. package/src/components/Sidebar/sidebar.spec.ts +0 -33
  117. package/src/components/Snackbar/RSnackbar.vue +0 -136
  118. package/src/components/Snackbar/Snackbar.mdx +0 -126
  119. package/src/components/Snackbar/Snackbar.stories.ts +0 -93
  120. package/src/components/Snackbar/snackbar.css +0 -99
  121. package/src/components/Snackbar/snackbar.spec.ts +0 -56
  122. package/src/components/Switch/RSwitch.vue +0 -147
  123. package/src/components/Switch/Switch.mdx +0 -102
  124. package/src/components/Switch/Switch.stories.ts +0 -79
  125. package/src/components/Switch/switch.css +0 -102
  126. package/src/components/Switch/switch.spec.ts +0 -31
  127. package/src/components/TabItem/RTabItem.vue +0 -175
  128. package/src/components/TabItem/TabItem.mdx +0 -95
  129. package/src/components/TabItem/TabItem.spec.ts +0 -29
  130. package/src/components/TabItem/TabItem.stories.ts +0 -97
  131. package/src/components/TabItem/common.ts +0 -6
  132. package/src/components/TabItem/tab-item.css +0 -29
  133. package/src/components/Tabs/RTabs.vue +0 -94
  134. package/src/components/Tabs/Tabs.mdx +0 -78
  135. package/src/components/Tabs/Tabs.spec.ts +0 -28
  136. package/src/components/Tabs/Tabs.stories.ts +0 -191
  137. package/src/components/Tabs/tabs.css +0 -13
  138. package/src/components/Tabs/types.ts +0 -11
  139. package/src/components/TextArea/RTextArea.vue +0 -142
  140. package/src/components/TextArea/TextArea.mdx +0 -108
  141. package/src/components/TextArea/TextArea.stories.ts +0 -55
  142. package/src/components/TextArea/textarea.css +0 -51
  143. package/src/components/TextArea/textarea.spec.ts +0 -36
  144. package/src/components/Textfield/RTextfield.vue +0 -372
  145. package/src/components/Textfield/Textfield.mdx +0 -159
  146. package/src/components/Textfield/Textfield.stories.ts +0 -121
  147. package/src/components/Textfield/textfield.css +0 -81
  148. package/src/components/Textfield/textfield.spec.ts +0 -34
  149. package/src/components/Tooltip/RTooltip.vue +0 -325
  150. package/src/components/Tooltip/Tooltip.mdx +0 -111
  151. package/src/components/Tooltip/Tooltip.stories.ts +0 -203
  152. package/src/components/Tooltip/common.ts +0 -91
  153. package/src/components/Tooltip/tooltip.css +0 -34
  154. package/src/components/Tooltip/tooltip.spec.ts +0 -81
  155. package/src/components/Typography/Typography.mdx +0 -109
  156. package/src/components/Typography/typography.css +0 -128
  157. package/src/directives/index.ts +0 -19
  158. package/src/index.css +0 -241
  159. package/src/main.ts +0 -5
  160. package/src/scripts/buildIcons.js +0 -21
  161. package/src/stories/Colors.mdx +0 -355
  162. package/src/stories/GettingStarted.mdx +0 -121
  163. package/src/stories/Layout.mdx +0 -15
  164. package/tailwind.config.cjs +0 -16
  165. package/tsconfig.json +0 -24
  166. package/vite.config.ts +0 -39
  167. package/vitest.config.ts +0 -12
  168. /package/{public → dist}/design-tokens.source.json +0 -0
  169. /package/{public → dist}/favicon.ico +0 -0
@@ -1,99 +0,0 @@
1
- @import '../../index.css';
2
-
3
- .r-snackbar {
4
- @apply text-white gap-3 opacity-0 absolute w-[412px] grid items-center bg-[var(--neutral-900)] px-4 py-3.5 rounded-lg;
5
- grid-template-columns: auto 1fr auto;
6
-
7
- &--success {
8
- @apply bg-[var(--success-500)];
9
- }
10
-
11
- &--error {
12
- @apply bg-[var(--error-500)];
13
- }
14
-
15
- &--warning {
16
- @apply bg-[var(--warning-500)];
17
- }
18
-
19
- &--info {
20
- @apply bg-[var(--info-500)];
21
- }
22
-
23
- &__text {
24
- @apply text-sm pr-16;
25
- }
26
- &__close {
27
- @apply cursor-pointer grid place-items-center;
28
- }
29
-
30
- &__right {
31
- @apply right-6 left-auto;
32
- }
33
-
34
- &__left {
35
- @apply left-0 right-auto;
36
- }
37
-
38
- &__top {
39
- @apply top-20 bottom-auto;
40
- }
41
-
42
- &__bottom {
43
- @apply bottom-20 top-auto;
44
- }
45
-
46
- &--shown {
47
- @apply opacity-100 transition-all duration-300 ease-in-out;
48
- animation: slide-right-to-right 0.3s ease-in-out forwards;
49
- }
50
-
51
- &--hidden {
52
- @apply transition-all duration-300 ease-in-out;
53
- animation: slide-left-from-right 0.3s ease-in-out forwards;
54
- }
55
-
56
- &--shown:not(.r-snackbar__right) {
57
- animation: slide-right-from-left 0.1s ease-in-out forwards;
58
- }
59
-
60
- &--hidden:not(.r-snackbar__right) {
61
- animation: slide-left-to-left 0.2s ease-in-out forwards;
62
- }
63
- }
64
-
65
- @keyframes slide-left-from-right {
66
- 0% {
67
- transform: translateX(-50%);
68
- }
69
- 100% {
70
- transform: translateX(100%);
71
- }
72
- }
73
-
74
- @keyframes slide-right-to-right {
75
- 0% {
76
- transform: translateX(100%);
77
- }
78
- 100% {
79
- transform: translateX(0);
80
- }
81
- }
82
-
83
- @keyframes slide-right-from-left {
84
- 0% {
85
- transform: translateX(-100%);
86
- }
87
- 100% {
88
- transform: translateX(10%);
89
- }
90
- }
91
-
92
- @keyframes slide-left-to-left {
93
- 0% {
94
- transform: translateX(50%);
95
- }
96
- 100% {
97
- transform: translateX(-50%);
98
- }
99
- }
@@ -1,56 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
- import Snackbar from './RSnackbar.vue';
5
-
6
- describe('Snackbar', () => {
7
- it('renders properly', () => {
8
- const wrapper = mount(Snackbar, {
9
- props: {
10
- text: 'Snackbar text',
11
- },
12
- });
13
- expect(wrapper.exists()).toBe(true);
14
- expect(wrapper.find('.snackbar').exists()).toBe(true);
15
- expect(wrapper.find('.snackbar__text').exists()).toBe(true);
16
- expect(wrapper.find('.snackbar__text').text()).toBe('Snackbar text');
17
- expect(wrapper.find('.snackbar__action').exists()).toBe(false);
18
- expect(wrapper.find('.snackbar__close').exists()).toBe(false);
19
- });
20
- it('with action', () => {
21
- const wrapper = mount(Snackbar, {
22
- props: {
23
- text: 'Snackbar text',
24
- actionText: 'Action',
25
- showAction: true,
26
- },
27
- });
28
- expect(wrapper.exists()).toBe(true);
29
- expect(wrapper.find('.snackbar').exists()).toBe(true);
30
- expect(wrapper.find('.snackbar__action').exists()).toBe(true);
31
- expect(wrapper.find('.snackbar__action').text()).toBe('Action');
32
- });
33
- it('with close', () => {
34
- const wrapper = mount(Snackbar, {
35
- props: {
36
- text: 'Snackbar text',
37
- showClose: true,
38
- },
39
- });
40
- expect(wrapper.exists()).toBe(true);
41
- expect(wrapper.find('.snackbar').exists()).toBe(true);
42
- expect(wrapper.find('.snackbar__close').exists()).toBe(true);
43
- });
44
- it('with timeout', async () => {
45
- const wrapper = mount(Snackbar, {
46
- props: {
47
- text: 'Snackbar text',
48
- timeout: 100,
49
- },
50
- });
51
- expect(wrapper.exists()).toBe(true);
52
- expect(wrapper.find('.snackbar').exists()).toBe(true);
53
- await new Promise((resolve) => setTimeout(resolve, 200));
54
- expect(wrapper.find('.snackbar--closed').exists()).toBe(true);
55
- });
56
- });
@@ -1,147 +0,0 @@
1
- <script setup lang="ts">
2
- import {
3
- computed,
4
- reactive,
5
- watch,
6
- type HTMLAttributes,
7
- type InputHTMLAttributes,
8
- type LabelHTMLAttributes,
9
- } from 'vue';
10
- import './switch.css';
11
- export interface Props {
12
- /**
13
- * id of the checkbox
14
- * @type HTMLAttributes['id']
15
- * @default ''
16
- * @example
17
- * <Checkbox id="checkbox" />
18
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
19
- */
20
- id: HTMLAttributes['id'];
21
-
22
- /**
23
- * Input checked state
24
- * @type InputHTMLAttributes['checked']
25
- * @default false
26
- * @example
27
- * <Checkbox modelValue="true" />
28
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#checked
29
- */
30
- modelValue?: InputHTMLAttributes['checked'];
31
-
32
- /**
33
- * Input disabled state
34
- * @type InputHTMLAttributes['disabled']
35
- * @default false
36
- * @example
37
- * <Checkbox disabled="true" />
38
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#disabled
39
- */
40
- disabled?: InputHTMLAttributes['disabled'];
41
-
42
- /**
43
- * label of the checkbox
44
- * @type LabelHTMLAttributes['label']
45
- * @default ''
46
- * @example
47
- * <Checkbox label="Checkbox" />
48
- * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label
49
- */
50
- label?: LabelHTMLAttributes['for'];
51
-
52
- /**
53
- * Hint text
54
- * @type string
55
- * @default ''
56
- * @example
57
- * <Checkbox hint="This is a hint" />
58
- */
59
- hint?: string;
60
-
61
- /**
62
- * Error message
63
- * @type string
64
- * @default ''
65
- * @example
66
- * <Checkbox errorMsg="This is an error" />
67
- */
68
- errorMsg?: string;
69
-
70
- /**
71
- * Size of the checkbox
72
- * @type 'small' | 'medium' | 'large'
73
- * @default 'medium'
74
- * @example
75
- * <Checkbox size="small" />
76
- */
77
- size?: 'small' | 'medium' | 'large';
78
- }
79
- const props = withDefaults(defineProps<Props>(), {
80
- id: 'switch',
81
- modelValue: false,
82
- size: 'medium',
83
- disabled: false,
84
- label: '',
85
- hint: '',
86
- errorMsg: '',
87
- });
88
- const emit = defineEmits(['update:modelValue']);
89
- const state = reactive<{
90
- checked: InputHTMLAttributes['checked'];
91
- }>({
92
- checked: false,
93
- });
94
- const classes = computed(() => {
95
- return {
96
- switch: true,
97
- 'switch--disabled': props.disabled,
98
- [`switch--${props.size}`]: props.size,
99
- 'switch--error': props.errorMsg,
100
- };
101
- });
102
- const onChange = (e: unknown) => {
103
- if (props.disabled) return;
104
- // @ts-expect-error: Unreachable code error
105
- state.checked = e.target.checked;
106
- emit('update:modelValue', state.checked);
107
- };
108
- watch(
109
- () => props.modelValue,
110
- (value) => {
111
- state.checked = value;
112
- },
113
- {
114
- // need immediate to set the state on first render for storybook
115
- // TODO: find a better way to do this
116
- immediate: true,
117
- }
118
- );
119
- </script>
120
- <template>
121
- <div class="switch-container">
122
- <div :class="classes">
123
- <input
124
- :id="props.id"
125
- :checked="state.checked"
126
- class="switch__input"
127
- type="checkbox"
128
- @change="onChange"
129
- />
130
- <span class="slider round" />
131
- </div>
132
- <div
133
- :class="{
134
- 'switch-texts': true,
135
- [`switch-texts--${props.size}`]: true,
136
- }"
137
- >
138
- <label :id="props.id" class="switch-texts__label" :for="props.id">
139
- {{ props.label }}
140
- </label>
141
- <p v-if="props.errorMsg" class="switch-texts__error">
142
- {{ props.errorMsg }}
143
- </p>
144
- <p v-else class="switch-texts__hint">{{ props.hint }}</p>
145
- </div>
146
- </div>
147
- </template>
@@ -1,102 +0,0 @@
1
- import { Canvas, Meta, Story, Controls } from '@storybook/blocks';
2
- import * as SwitchStories from './Switch.stories';
3
-
4
- <Meta of={SwitchStories} />
5
-
6
- # Switch
7
-
8
- - [Overview](#overview)
9
-
10
- - [Playground](#playground)
11
-
12
- - [Usage with props](#usage)
13
-
14
- - [Stories](#stories)
15
-
16
- - [Tips](#tips)
17
-
18
- ### Overview <a id="overview" />
19
-
20
- The Switch component is a simple toggle that allows the user to switch between two states: on and off. It is designed to be used as a controlled component, meaning that the value prop must be provided and will determine the current state of the switch.
21
-
22
- <Canvas>
23
- <Story of={SwitchStories.Overview} />
24
- </Canvas>
25
-
26
- ### Playground <a id="playground" />
27
-
28
- > Changes you make in the controls will be reflected in the example above.
29
-
30
- <Controls of={SwitchStories.Overview} exclude={/^(on|change|onChange.*)$/} />
31
-
32
- ## Usage with props <a id="usage" />
33
-
34
- ### modelValue (required)
35
-
36
- The **modelValue** prop determines the current state of the switch. When the modelValue prop is true, the switch will be in the "on" state, and when it is false, the switch will be in the "off" state.
37
-
38
- ### size (optional)
39
-
40
- The **size** prop setermines the size of the switch. Accepts the values small, medium (default), and large.
41
-
42
- ### id (optional)
43
-
44
- The **id** prop sets the HTML id attribute on the switch element. This can be useful for connecting the switch to a label element using the for attribute.
45
-
46
- ### disabled (optional)
47
-
48
- If the **disabled** prop is true, the switch will be disabled and the user will not be able to toggle it.
49
-
50
- ### label (optional)
51
-
52
- The **label** prop sets the label text for the switch. This can be used to provide additional context or instructions for the switch.
53
-
54
- ### hint (optional)
55
-
56
- The **hint** prop sets a hint text for the switch. This can be used to provide additional information about the switch, such as its purpose or how it is used.
57
-
58
- ### errorMsg (optional)
59
-
60
- The **errorMsg** prop sets an error message for the switch. This can be used to display an error message when the switch is in an invalid state or when it has been used in an incorrect way.
61
-
62
- ## Stories <a id="stories" />
63
-
64
- ### Small
65
-
66
- <Canvas>
67
- <Story of={SwitchStories.Small} />
68
- </Canvas>
69
-
70
- ### Medium
71
-
72
- <Canvas>
73
- <Story of={SwitchStories.Medium} />
74
- </Canvas>
75
-
76
- ### Large
77
-
78
- <Canvas>
79
- <Story of={SwitchStories.Large} />
80
- </Canvas>
81
-
82
- ### With Error
83
-
84
- <Canvas>
85
- <Story of={SwitchStories.WithError} />
86
- </Canvas>
87
-
88
- ### Tips <a id="tips" />
89
-
90
- 💡 Use the label prop to provide context or instructions for the switch. This can help the user understand what the switch is for and how to use it.
91
-
92
- 💡 Use the hint prop to provide additional information about the switch. This can be helpful if the switch is being used for a less common or more complex feature.
93
-
94
- 💡 Use the errorMsg prop to display an error message when the switch is in an invalid state or when it has been used in an incorrect way. This can help the user understand why the switch is not working as expected.
95
-
96
- 💡 Use the size prop to adjust the size of the switch to fit the layout and design of your application.
97
-
98
- 💡 Use the disabled prop to disable the switch when it is not needed or when it should not be used.
99
-
100
- 💡 Use the onChange prop to update the state of the switch and control its behavior. This is especially important when using the Switch component as a controlled component.
101
-
102
- 💡 Consider using the Switch component as a controlled component, which means that the value prop must be provided and will determine the current state of the switch. This can help ensure that the state of the switch is always in sync with the rest of your application.
@@ -1,79 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/vue3';
2
- import Switch from './RSwitch.vue';
3
-
4
- const DefaultArgTypes = {
5
- size: {
6
- control: {
7
- type: 'select',
8
- options: ['small', 'medium', 'large'],
9
- },
10
- defaultValue: 'medium',
11
- },
12
- };
13
-
14
- const DefaultArgs = {
15
- id: 'switch',
16
- modelValue: false,
17
- size: 'medium',
18
- disabled: false,
19
- label: 'Switch',
20
- hint: 'A control used to switch between two states: often on or off.',
21
- };
22
-
23
- const SwitchStory = {
24
- title: 'Form/Switch',
25
- component: Switch,
26
- setup(args: typeof Switch) {
27
- return {
28
- args,
29
- };
30
- },
31
- template: `<Switch v-bind="args"/>`,
32
- args: DefaultArgs,
33
- argTypes: {
34
- ...DefaultArgTypes,
35
- 'onUpdate:modelValue': {
36
- action: 'update:modelValue',
37
- },
38
- },
39
- } as Meta<typeof Switch>;
40
-
41
- export default SwitchStory;
42
-
43
- type Story = StoryObj<typeof SwitchStory>;
44
-
45
- export const Overview: Story = {
46
- args: {
47
- modelValue: false,
48
- size: 'small',
49
- },
50
- };
51
-
52
- export const Small: Story = {
53
- args: {
54
- modelValue: false,
55
- size: 'small',
56
- },
57
- };
58
-
59
- export const Medium: Story = {
60
- args: {
61
- modelValue: false,
62
- size: 'medium',
63
- },
64
- };
65
-
66
- export const Large: Story = {
67
- args: {
68
- modelValue: false,
69
- size: 'large',
70
- },
71
- };
72
-
73
- export const WithError: Story = {
74
- args: {
75
- modelValue: false,
76
- size: 'medium',
77
- errorMsg: 'This is an error message',
78
- },
79
- };
@@ -1,102 +0,0 @@
1
- @import '../../index.css';
2
-
3
- .switch-container {
4
- @apply flex items-center justify-start gap-3;
5
- }
6
-
7
- .slider {
8
- @apply absolute top-0 left-0 right-0 bottom-0 bg-[var(--neutral-300)] rounded-full;
9
-
10
- &::before {
11
- content: '';
12
- @apply absolute left-1 bottom-1 bg-white transition-all duration-200 ease-in-out rounded-full;
13
- }
14
- }
15
-
16
- .switch {
17
- @apply relative inline-block w-16 h-9 box-border;
18
-
19
- &--small {
20
- @apply w-9 h-5;
21
-
22
- & > .slider::before {
23
- @apply w-3 h-3;
24
- }
25
- & > .switch__input:checked + .slider:before {
26
- -webkit-transform: translateX(16px);
27
- -ms-transform: translateX(16px);
28
- transform: translateX(16px);
29
- }
30
- }
31
- &--medium {
32
- @apply w-11 h-6;
33
- & > .slider::before {
34
- @apply w-4 h-4;
35
- }
36
- & > .switch__input:checked + .slider:before {
37
- -webkit-transform: translateX(20px);
38
- -ms-transform: translateX(20px);
39
- transform: translateX(20px);
40
- }
41
- }
42
- &--large {
43
- @apply w-[3.25rem] h-7;
44
-
45
- & > .slider::before {
46
- @apply w-5 h-5;
47
- }
48
- & > .switch__input:checked + .slider:before {
49
- -webkit-transform: translateX(24px);
50
- -ms-transform: translateX(24px);
51
- transform: translateX(24px);
52
- }
53
- }
54
-
55
- &--disabled {
56
- @apply cursor-not-allowed;
57
- & > .slider::before {
58
- @apply bg-[var(--neutral-200)];
59
- }
60
- }
61
-
62
- &--error {
63
- & > .switch__input:checked + .slider {
64
- @apply bg-[var(--error-500)];
65
- &:hover {
66
- @apply bg-[var(--error-700)];
67
- }
68
- }
69
- }
70
-
71
- &__input {
72
- @apply absolute left-1/2 -translate-x-1/2 w-full h-full appearance-none rounded-md z-20 cursor-pointer;
73
- &:checked + .slider {
74
- @apply bg-[var(--primary-500)];
75
- &:hover {
76
- @apply bg-[var(--primary-700)];
77
- }
78
- }
79
- }
80
- }
81
-
82
- .switch-texts {
83
- &--small {
84
- @apply text-xs;
85
- }
86
- &--medium {
87
- @apply text-sm;
88
- }
89
- &--large {
90
- @apply text-base;
91
- }
92
-
93
- &__label {
94
- @apply font-medium text-[var(--neutral-900)] p-0 m-0;
95
- }
96
- &__hint {
97
- @apply text-[var(--neutral-500)] font-normal p-0 m-0;
98
- }
99
- &__error {
100
- @apply text-[var(--error-500)] font-normal p-0 m-0;
101
- }
102
- }
@@ -1,31 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
-
3
- import { mount } from '@vue/test-utils';
4
- import Switch from './RSwitch.vue';
5
-
6
- describe('Switch', () => {
7
- it('renders properly', () => {
8
- const wrapper = mount(Switch, {
9
- props: {
10
- id: 'switch-id',
11
- disabled: false,
12
- size: 'small',
13
- },
14
- });
15
- expect(wrapper.exists()).toBe(true);
16
- expect(wrapper.find('label').exists()).toBe(true);
17
- expect(wrapper.find('label').element.getAttribute('for')).toBe('switch-id');
18
- expect(wrapper.find('input').exists()).toBe(true);
19
- expect(wrapper.find('input').element.getAttribute('id')).toBe('switch-id');
20
- expect(wrapper.find('input').element.getAttribute('type')).toBe('checkbox');
21
- expect(wrapper.find('input').element.getAttribute('disabled')).toBe(null);
22
- expect(
23
- wrapper
24
- .find('.switch')
25
- .trigger('click')
26
- .then(() => {
27
- expect(wrapper.find('input').element.checked).toBe(true);
28
- })
29
- );
30
- });
31
- });