@redseed/redseed-ui-vue3 2.21.0 → 2.22.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redseed/redseed-ui-vue3",
3
- "version": "2.21.0",
3
+ "version": "2.22.0",
4
4
  "description": "RedSeed UI Vue 3 components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,164 @@
1
+ <script setup>
2
+ import { ref, computed, watch } from 'vue'
3
+ import ButtonTertiary from '../Button/ButtonTertiary.vue'
4
+
5
+ const props = defineProps({
6
+ showButton: {
7
+ type: Boolean,
8
+ default: false,
9
+ },
10
+ deselectable: {
11
+ type: Boolean,
12
+ default: false,
13
+ },
14
+ selected: {
15
+ type: Boolean,
16
+ default: false,
17
+ },
18
+ disabled: {
19
+ type: Boolean,
20
+ default: false,
21
+ },
22
+ })
23
+
24
+ const isSelected = ref(props.selected)
25
+
26
+ watch(() => props.selected, () => {
27
+ isSelected.value = props.selected
28
+ })
29
+
30
+ const componentClass = computed(() => [
31
+ 'rsui-radio-card',
32
+ 'group/radio-card',
33
+ {
34
+ 'rsui-radio-card--selected': isSelected.value,
35
+ 'rsui-radio-card--disabled': props.disabled,
36
+ },
37
+ ])
38
+
39
+ const titleRowClass = computed(() => [
40
+ 'rsui-radio-card__title-row',
41
+ {
42
+ 'rsui-radio-card__title-row--selected': isSelected.value && !props.disabled,
43
+ 'rsui-radio-card__title-row--disabled': props.disabled && !isSelected.value,
44
+ 'rsui-radio-card__title-row--selected-disabled': isSelected.value && props.disabled,
45
+ },
46
+ ])
47
+
48
+ const emit = defineEmits(['select', 'deselect', 'click'])
49
+
50
+ function handleSelect() {
51
+ if (props.disabled) return
52
+ if (!props.deselectable && isSelected.value) return
53
+
54
+ isSelected.value = !isSelected.value
55
+
56
+ if (props.deselectable && !isSelected.value) {
57
+ emit('deselect', isSelected.value)
58
+ return
59
+ }
60
+
61
+ emit('select', isSelected.value)
62
+ return
63
+ }
64
+
65
+ function handleClick(event) {
66
+ if (props.disabled) return
67
+
68
+ event.stopPropagation()
69
+
70
+ console.log('click')
71
+
72
+ emit('click', event)
73
+ }
74
+ </script>
75
+ <template>
76
+ <div :class="componentClass"
77
+ @click="handleSelect"
78
+ role="radio"
79
+ tabindex="0"
80
+ >
81
+ <div :class="titleRowClass">
82
+ <div class="rsui-radio-card__title">
83
+ <slot name="title"></slot>
84
+ </div>
85
+ </div>
86
+
87
+ <div class="rsui-radio-card__content-row" v-if="$slots.default">
88
+ <slot></slot>
89
+ </div>
90
+
91
+ <div class="rsui-radio-card__meta-row" v-if="$slots.meta">
92
+ <slot name="meta"></slot>
93
+ </div>
94
+
95
+ <div class="rsui-radio-card__action-row" v-if="showButton">
96
+ <ButtonTertiary xs @click="handleClick">
97
+ <slot name="button-label">Button</slot>
98
+ </ButtonTertiary>
99
+ </div>
100
+ </div>
101
+ </template>
102
+ <style lang="scss" scoped>
103
+ .rsui-radio-card {
104
+ @apply max-w-80 w-80 bg-white border border-rsui-grey-200 rounded-md shadow-sm outline-none select-none;
105
+ @apply relative cursor-pointer transition-all;
106
+ @apply flex flex-col gap-3 p-4;
107
+ @apply focus-visible:ring-4 focus-visible:ring-rsui-light;
108
+
109
+ &--selected {
110
+ @apply bg-primary/10 border-primary;
111
+ @apply focus-visible:ring-4 focus-visible:ring-primary/10;
112
+ }
113
+
114
+ &--disabled {
115
+ @apply bg-white border-rsui-grey-200 focus-visible:ring-0 cursor-default;
116
+ @apply after:absolute after:content-[''] after:inset-0 after:bg-rsui-grey-200/65;
117
+ @apply after:rounded-md;
118
+ }
119
+
120
+ &__title-row {
121
+ @apply relative text-base font-medium text-rsui-default line-clamp-2 min-h-6;
122
+
123
+ // Radio button position
124
+ @apply after:absolute after:top-0 after:right-0;
125
+ // Radio button shape
126
+ @apply after:content-[''] after:size-6 after:rounded-full;
127
+ // Radio button animation
128
+ @apply after:transition-all;
129
+ // Radio button decoration
130
+ @apply after:border after:border-rsui-light after:bg-white;
131
+ // Radio button event
132
+ @apply group-hover/radio-card:after:border-rsui-medium;
133
+ @apply group-focus-visible/radio-card:after:border-rsui-medium;
134
+
135
+ &--selected {
136
+ @apply after:border-6 after:border-primary;
137
+ @apply group-hover/radio-card:after:border-primary;
138
+ @apply group-focus-visible/radio-card:after:border-primary;
139
+ }
140
+
141
+ &--disabled {
142
+ @apply after:opacity-0;
143
+ }
144
+
145
+ &--selected-disabled {
146
+ @apply after:border-6 after:border-white after:bg-rsui-light;
147
+ @apply group-hover/radio-card:after:border-white;
148
+ @apply group-focus-visible/radio-card:after:border-white;
149
+ }
150
+ }
151
+
152
+ &__content-row {
153
+ @apply text-sm font-normal text-rsui-medium;
154
+ }
155
+
156
+ &__meta-row {
157
+ @apply grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-2;
158
+ }
159
+
160
+ &__action-row {
161
+ @apply flex flex-wrap gap-2;
162
+ }
163
+ }
164
+ </style>
@@ -1,7 +1,9 @@
1
1
  import Card from './Card.vue'
2
2
  import CardResource from './CardResource.vue'
3
+ import RadioCard from './RadioCard.vue'
3
4
 
4
5
  export {
5
6
  Card,
6
7
  CardResource,
7
- }
8
+ RadioCard,
9
+ }
@@ -67,7 +67,7 @@ function handleStepClick(clickedStep) {
67
67
  </template>
68
68
  <style lang="scss" scoped>
69
69
  .rsui-progress-tracker {
70
- @apply grid grid-flow-col auto-cols-fr gap-16;
71
- @apply text-xl font-medium;
70
+ @apply grid grid-flow-col auto-cols-fr gap-8 sm:gap-16;
71
+ @apply text-xs sm:text-xl font-medium;
72
72
  }
73
73
  </style>
@@ -74,12 +74,12 @@ function handleClick() {
74
74
  </template>
75
75
  <style lang="scss" scoped>
76
76
  .rsui-progress-tracker-step {
77
- @apply relative flex flex-col items-center text-center gap-4;
77
+ @apply relative flex flex-col items-center text-center gap-3 sm:gap-4;
78
78
 
79
79
  // add a line before each step
80
80
  @apply after:content-[''] after:absolute after:bg-rsui-grey-300;
81
- @apply after:top-6 after:-left-8 after:-translate-x-1/2;
82
- @apply after:w-[160%] xs:after:w-[140%] lg:after:w-[120%] 3xl:after:w-[104%] after:h-1;
81
+ @apply after:top-3.5 sm:after:top-6 after:-left-4 sm:after:-left-8 after:-translate-x-1/2;
82
+ @apply after:w-[100%] xs:after:w-[140%] sm:after:w-[140%] lg:after:w-[120%] 3xl:after:w-[107%] after:h-1;
83
83
  // hide the line before the first step
84
84
  @apply first:after:hidden;
85
85
 
@@ -93,7 +93,7 @@ function handleClick() {
93
93
  }
94
94
 
95
95
  &__indicator {
96
- @apply relative z-1 size-13 rounded-full border-2 overflow-hidden select-none;
96
+ @apply relative z-1 size-8 sm:size-13 rounded-full border-2 overflow-hidden select-none;
97
97
  @apply bg-rsui-grey-300 border-rsui-grey-300 text-white;
98
98
  @apply flex items-center justify-center;
99
99
  &--completed {