srcdev-nuxt-components 9.1.43 → 9.1.44

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.
@@ -1,187 +0,0 @@
1
- <template>
2
- <component :is="tag" class="display-chip-core" :class="[shape, elementClasses]" :style="chipStyles">
3
- <slot name="default"></slot>
4
- <Icon v-if="config?.icon" :name="config.icon" class="chip-icon" />
5
- <span v-if="config?.label" class="chip-label" :class="`length-${config.label.length}`">{{ validatedLabel }}</span>
6
- </component>
7
- </template>
8
-
9
- <script setup lang="ts">
10
- import type { DisplayChipConfig } from "../../types/components"
11
-
12
- const props = defineProps({
13
- tag: {
14
- type: String as PropType<"div" | "span">,
15
- default: "div",
16
- },
17
- shape: {
18
- type: String as PropType<"circle" | "square">,
19
- default: "circle",
20
- },
21
- config: {
22
- type: Object as PropType<DisplayChipConfig>,
23
- default: () => ({
24
- size: "12px",
25
- maskWidth: "4px",
26
- offset: "0px",
27
- angle: "90deg",
28
- icon: undefined,
29
- label: undefined,
30
- }),
31
- },
32
- styleClassPassthrough: {
33
- type: [String, Array] as PropType<string | string[]>,
34
- default: () => [],
35
- },
36
- })
37
-
38
- const { elementClasses } = useStyleClassPassthrough(props.styleClassPassthrough)
39
-
40
- const validatedLabel = computed(() => {
41
- if (!props.config?.label) return props.config?.label
42
- if (props.config.label.length > 3) {
43
- console.warn(
44
- `DisplayChip: label "${
45
- props.config.label
46
- }" exceeds maximum length of 3 characters. Truncating to "${props.config.label.slice(0, 3)}"`
47
- )
48
- return props.config.label.slice(0, 3)
49
- }
50
- return props.config.label
51
- })
52
-
53
- const chipStyles = computed(() => ({
54
- "--chip-size": props.config?.size,
55
- "--chip-mask-width": props.config?.maskWidth,
56
- "--chip-offset": props.config?.offset,
57
- "--chip-angle": props.config?.angle,
58
- }))
59
- </script>
60
-
61
- <style lang="css">
62
- @layer components {
63
- .display-chip-core {
64
- --computed-mask-diameter: calc(var(--chip-size) + (var(--chip-mask-width) * 2));
65
-
66
- &.circle {
67
- --computed-chip-offset: calc((100% / 2) + var(--chip-offset));
68
- --computed-position-x: calc(var(--computed-chip-offset) * cos(var(--chip-angle) - 90deg) + (100% / 2));
69
- --computed-position-y: calc(var(--computed-chip-offset) * sin(var(--chip-angle) - 90deg) + (100% / 2));
70
- }
71
-
72
- &.square {
73
- --circle-x: calc(50% + (50% + var(--chip-offset) + (var(--chip-size) / 2)) * cos(var(--chip-angle) - 90deg));
74
- --circle-y: calc(50% + (50% + var(--chip-offset) + (var(--chip-size) / 2)) * sin(var(--chip-angle) - 90deg));
75
- --computed-position-x: clamp(calc(var(--chip-offset) * -1), var(--circle-x), calc(100% + var(--chip-offset)));
76
- --computed-position-y: clamp(calc(var(--chip-offset) * -1), var(--circle-y), calc(100% + var(--chip-offset)));
77
- }
78
-
79
- /* colors */
80
-
81
- --color-offline: slategrey;
82
- --color-online: rgb(0, 255, 135);
83
- --color-idle: rgb(255, 185, 51);
84
- --color-dnd: rgb(255, 40, 80);
85
-
86
- position: relative;
87
- display: inline-block;
88
-
89
- &::after {
90
- content: "";
91
- aspect-ratio: 1;
92
- background: var(--color-offline);
93
- position: absolute;
94
- width: var(--chip-size);
95
- border-radius: 100%;
96
- z-index: 1;
97
- }
98
- .chip-icon {
99
- position: absolute;
100
- width: var(--chip-size);
101
- height: var(--chip-size);
102
- border-radius: 100%;
103
- display: flex;
104
- align-items: center;
105
- justify-content: center;
106
- color: black;
107
- z-index: 2;
108
- }
109
-
110
- .chip-label {
111
- --_font-size-adjust: 0.7;
112
- position: absolute;
113
- width: var(--chip-size);
114
- height: var(--chip-size);
115
- border-radius: 100%;
116
- display: flex;
117
- align-items: center;
118
- justify-content: center;
119
- color: black;
120
- z-index: 2;
121
- font-size: calc(var(--chip-size) * var(--_font-size-adjust));
122
- line-height: 1;
123
- letter-spacing: -0.05rem;
124
- user-select: none;
125
-
126
- &.length-2 {
127
- --_font-size-adjust: 0.6;
128
- }
129
-
130
- &.length-3 {
131
- --_font-size-adjust: 0.5;
132
- }
133
- }
134
-
135
- & > * {
136
- /*
137
- create the cutout mask around the image,
138
- it's just a radial gradient positioned at the same place as the
139
- psuedo-element ::after
140
- */
141
-
142
- &:not(.chip-icon, .chip-label) {
143
- mask-image: radial-gradient(
144
- var(--computed-mask-diameter) var(--computed-mask-diameter) at var(--computed-position-x)
145
- var(--computed-position-y),
146
- transparent calc(50% - 0.5px),
147
- black calc(50% + 0.5px)
148
- );
149
- }
150
- }
151
-
152
- &.circle {
153
- &::after,
154
- .chip-icon,
155
- .chip-label {
156
- top: calc(var(--computed-position-y) - (var(--chip-size) / 2));
157
- left: calc(var(--computed-position-x) - (var(--chip-size) / 2));
158
- }
159
- }
160
-
161
- &.square {
162
- &::after,
163
- .chip-icon,
164
- .chip-label {
165
- top: calc(var(--computed-position-y) - (var(--chip-size) / 2));
166
- left: calc(var(--computed-position-x) - (var(--chip-size) / 2));
167
- }
168
- }
169
-
170
- &.online {
171
- &::after {
172
- background-color: var(--color-online);
173
- }
174
- }
175
- &.idle {
176
- &::after {
177
- background-color: var(--color-idle);
178
- }
179
- }
180
- &.dnd {
181
- &::after {
182
- background-color: var(--color-dnd);
183
- }
184
- }
185
- }
186
- }
187
- </style>