sprintify-ui 0.0.151 → 0.0.153

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,7 +1,7 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
2
2
  contrast: 'low' | 'high';
3
- color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
4
- size: 'sm' | 'base' | 'lg';
3
+ color: string;
4
+ size?: "base" | "sm" | "lg" | undefined;
5
5
  icon?: string | undefined;
6
6
  }>, {
7
7
  contrast: string;
@@ -10,8 +10,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
10
10
  icon: undefined;
11
11
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
12
12
  contrast: 'low' | 'high';
13
- color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
14
- size: 'sm' | 'base' | 'lg';
13
+ color: string;
14
+ size?: "base" | "sm" | "lg" | undefined;
15
15
  icon?: string | undefined;
16
16
  }>, {
17
17
  contrast: string;
@@ -19,7 +19,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
19
19
  size: string;
20
20
  icon: undefined;
21
21
  }>>>, {
22
- color: 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'indigo' | 'purple' | 'pink' | string;
22
+ color: string;
23
23
  icon: string;
24
24
  size: 'sm' | 'base' | 'lg';
25
25
  contrast: 'low' | 'high';
@@ -1,5 +1,6 @@
1
1
  import { PropType } from 'vue';
2
2
  import { CollectionItem, DataTableQuery, MenuItemInterface } from '@/types';
3
+ import { RouteLocationRaw } from 'vue-router';
3
4
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
4
5
  /**
5
6
  * Base URL from which to make requests
@@ -35,7 +36,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
35
36
  */
36
37
  editUrl: {
37
38
  default: undefined;
38
- type: PropType<(row: CollectionItem) => string>;
39
+ type: PropType<(row: CollectionItem) => RouteLocationRaw>;
39
40
  };
40
41
  /**
41
42
  * Show/Hide delete button
@@ -164,7 +165,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
164
165
  */
165
166
  editUrl: {
166
167
  default: undefined;
167
- type: PropType<(row: CollectionItem) => string>;
168
+ type: PropType<(row: CollectionItem) => RouteLocationRaw>;
168
169
  };
169
170
  /**
170
171
  * Show/Hide delete button
@@ -274,7 +275,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
274
275
  hasDetailedVisible: (row: any) => boolean;
275
276
  maxHeight: number;
276
277
  editButton: boolean;
277
- editUrl: (row: CollectionItem) => string;
278
+ editUrl: (row: CollectionItem) => RouteLocationRaw;
278
279
  deleteButton: boolean;
279
280
  deleteUrl: (row: CollectionItem) => string;
280
281
  toggleable: boolean;
@@ -19,7 +19,7 @@ declare const _default: import("vue").DefineComponent<{
19
19
  };
20
20
  color: {
21
21
  default: string;
22
- type: PropType<"gray" | "red" | "orange" | "yellow" | "green" | "blue" | "indigo" | "purple" | "pink">;
22
+ type: PropType<string>;
23
23
  };
24
24
  icon: {
25
25
  required: true;
@@ -48,7 +48,7 @@ declare const _default: import("vue").DefineComponent<{
48
48
  };
49
49
  color: {
50
50
  default: string;
51
- type: PropType<"gray" | "red" | "orange" | "yellow" | "green" | "blue" | "indigo" | "purple" | "pink">;
51
+ type: PropType<string>;
52
52
  };
53
53
  icon: {
54
54
  required: true;
@@ -59,7 +59,7 @@ declare const _default: import("vue").DefineComponent<{
59
59
  type: PropType<"high" | "low">;
60
60
  };
61
61
  }>>, {
62
- color: "gray" | "red" | "orange" | "yellow" | "green" | "blue" | "indigo" | "purple" | "pink";
62
+ color: string;
63
63
  description: string;
64
64
  contrast: "high" | "low";
65
65
  linkText: string;
@@ -0,0 +1,13 @@
1
+ declare const colors: import("tailwindcss/types/generated/colors").DefaultColors;
2
+ export { colors };
3
+ interface ColorConfig {
4
+ backgroundColor: string;
5
+ textColor: string;
6
+ borderColor: string;
7
+ }
8
+ interface ColorPalette {
9
+ low: ColorConfig;
10
+ high: ColorConfig;
11
+ }
12
+ export declare const palette: Record<string, ColorPalette>;
13
+ export declare function getColorConfig(color: string, contrast?: boolean): ColorConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprintify-ui",
3
- "version": "0.0.151",
3
+ "version": "0.0.153",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@headlessui/vue": "^1.7.4",
38
+ "color2k": "^2.0.1",
38
39
  "storybook": "^6.5.15"
39
40
  },
40
41
  "devDependencies": {
@@ -1,18 +1,8 @@
1
1
  import BaseBadge from './BaseBadge.vue';
2
2
 
3
- const colors = [
4
- 'gray',
5
- 'red',
6
- 'orange',
7
- 'yellow',
8
- 'green',
9
- 'blue',
10
- 'indigo',
11
- 'purple',
12
- 'pink',
13
- '#ff0000',
14
- '#dbeafe',
15
- ];
3
+ import { palette } from '@/utils/colors';
4
+
5
+ const colors = [...Object.keys(palette), '#ff0000', '#dbeafe'];
16
6
 
17
7
  const sizes = ['sm', 'base', 'lg'];
18
8
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <span
3
3
  class="inline-flex items-center rounded-full font-medium"
4
- :class="[colorClasses, sizeClasses]"
4
+ :class="[sizeClasses]"
5
5
  :style="colorStyle"
6
6
  >
7
7
  <BaseIcon v-if="icon" :icon="icon" :class="iconSizeClasses"> </BaseIcon>
@@ -10,23 +10,14 @@
10
10
  </template>
11
11
 
12
12
  <script lang="ts" setup>
13
+ import { getColorConfig } from '@/utils/colors';
13
14
  import { BaseIcon } from '.';
14
15
 
15
16
  const props = withDefaults(
16
17
  defineProps<{
17
18
  contrast: 'low' | 'high';
18
- color:
19
- | 'gray'
20
- | 'red'
21
- | 'orange'
22
- | 'yellow'
23
- | 'green'
24
- | 'blue'
25
- | 'indigo'
26
- | 'purple'
27
- | 'pink'
28
- | string;
29
- size: 'sm' | 'base' | 'lg';
19
+ color: string;
20
+ size?: 'sm' | 'base' | 'lg';
30
21
  icon?: string;
31
22
  }>(),
32
23
  {
@@ -37,84 +28,13 @@ const props = withDefaults(
37
28
  }
38
29
  );
39
30
 
40
- const colorClasses = computed(() => {
41
- if (props.color == 'gray') {
42
- if (props.contrast == 'high') {
43
- return 'bg-slate-600 text-white';
44
- }
45
- return 'bg-slate-100 text-slate-800';
46
- }
47
- if (props.color == 'red') {
48
- if (props.contrast == 'high') {
49
- return 'bg-red-600 text-white';
50
- }
51
- return 'bg-red-100 text-red-900';
52
- }
53
- if (props.color == 'orange') {
54
- if (props.contrast == 'high') {
55
- return 'bg-orange-500 text-white';
56
- }
57
- return 'bg-orange-100 text-yellow-900';
58
- }
59
- if (props.color == 'yellow') {
60
- if (props.contrast == 'high') {
61
- return 'bg-yellow-500 text-white';
62
- }
63
- return 'bg-yellow-100 text-yellow-900';
64
- }
65
- if (props.color == 'green') {
66
- if (props.contrast == 'high') {
67
- return 'bg-green-600 text-white';
68
- }
69
- return 'bg-green-100 text-green-900';
70
- }
71
- if (props.color == 'blue') {
72
- if (props.contrast == 'high') {
73
- return 'bg-blue-600 text-white';
74
- }
75
- return 'bg-blue-100 text-blue-900';
76
- }
77
- if (props.color == 'indigo') {
78
- if (props.contrast == 'high') {
79
- return 'bg-indigo-600 text-white';
80
- }
81
- return 'bg-indigo-100 text-indigo-900';
82
- }
83
- if (props.color == 'purple') {
84
- if (props.contrast == 'high') {
85
- return 'bg-purple-600 text-white';
86
- }
87
- return 'bg-purple-100 text-purple-900';
88
- }
89
- if (props.color == 'pink') {
90
- if (props.contrast == 'high') {
91
- return 'bg-pink-600 text-white';
92
- }
93
- return 'bg-pink-100 text-pink-900';
94
- }
95
- if (!props.color) {
96
- return 'bg-slate-100 text-slate-900';
97
- }
98
- return '';
99
- });
100
-
101
31
  const colorStyle = computed((): Record<string, string> => {
102
- if (
103
- props.color &&
104
- (props.color.startsWith('#') || props.color.startsWith('rgb'))
105
- ) {
106
- let textColor = 'white';
107
-
108
- if (props.contrast == 'low') {
109
- textColor = 'rgba(0,0,0,0.8)';
110
- }
32
+ const config = getColorConfig(props.color, props.contrast == 'high');
111
33
 
112
- return {
113
- backgroundColor: props.color,
114
- color: textColor,
115
- };
116
- }
117
- return {};
34
+ return {
35
+ backgroundColor: config.backgroundColor,
36
+ color: config.textColor,
37
+ };
118
38
  });
119
39
 
120
40
  const sizeClasses = computed(() => {
@@ -1,14 +1,10 @@
1
- import { createFieldStory, colors } from '../../.storybook/utils';
1
+ import { createFieldStory } from '../../.storybook/utils';
2
2
  import BaseColor from './BaseColor.vue';
3
3
  import ShowValue from '../../.storybook/components/ShowValue.vue';
4
4
 
5
5
  export default {
6
6
  title: 'Form/BaseColor',
7
7
  component: BaseColor,
8
- argTypes: {},
9
- args: {
10
- colors: colors,
11
- },
12
8
  decorators: [() => ({ template: '<div class="mb-36"><story/></div>' })],
13
9
  };
14
10
 
@@ -17,10 +17,17 @@
17
17
  <template #option="option">
18
18
  <div
19
19
  :style="{ backgroundColor: option.option.value + '' }"
20
- class="rounded-md border-none p-3"
20
+ class="box-border rounded-md border p-3"
21
21
  :class="[
22
- option.selected.value ? 'text-white' : 'text-transparent',
22
+ option.selected.value
23
+ ? option.option.option.hasLowContrast
24
+ ? 'text-slate-700'
25
+ : 'text-white'
26
+ : 'text-transparent',
23
27
  disabled ? ' cursor-not-allowed opacity-50' : '',
28
+ option.option.option.hasLowContrast
29
+ ? 'border-slate-400'
30
+ : 'border-transparent',
24
31
  ]"
25
32
  >
26
33
  <BaseIcon icon="heroicons-solid:check-circle" class="h-5 w-5" />
@@ -36,6 +43,8 @@ import { BaseButtonGroup } from '.';
36
43
  import { isArray } from 'lodash';
37
44
  import { useField } from '@/composables/field';
38
45
  import { Option } from '@/types';
46
+ import { palette } from '@/utils/colors';
47
+ import { getContrast } from 'color2k';
39
48
 
40
49
  const props = defineProps({
41
50
  modelValue: {
@@ -59,19 +68,7 @@ const props = defineProps({
59
68
  colors: {
60
69
  type: [Array] as PropType<string[]>,
61
70
  default() {
62
- return [
63
- '#0f172a',
64
- '#dc2626',
65
- '#ea580c',
66
- '#eab308',
67
- '#16a34a',
68
- '#0d9488',
69
- '#0891b2',
70
- '#2563eb',
71
- '#4f46e5',
72
- '#9333ea',
73
- '#db2777',
74
- ];
71
+ return Object.values(palette).map((p) => p.high.backgroundColor);
75
72
  },
76
73
  },
77
74
  multiple: {
@@ -95,10 +92,15 @@ const colorOptions = computed(() => {
95
92
  return {
96
93
  label: c,
97
94
  value: c,
95
+ hasLowContrast: hasLowContrast(c),
98
96
  };
99
97
  });
100
98
  });
101
99
 
100
+ function hasLowContrast(color: string): boolean {
101
+ return getContrast(color, '#fff') < 1.38;
102
+ }
103
+
102
104
  const normalizeModelValue = computed(() => {
103
105
  return isArray(props.modelValue)
104
106
  ? props.modelValue?.map((m) => {
@@ -187,6 +187,7 @@ import BaseTableColumn from './BaseTableColumn.vue';
187
187
  import BaseDataTableToggleColumns from './BaseDataTableToggleColumns.vue';
188
188
  import { config } from '@/index';
189
189
  import BaseEmptyState from '../svg/BaseEmptyState.vue';
190
+ import { RouteLocationRaw } from 'vue-router';
190
191
 
191
192
  const i18n = useI18n();
192
193
 
@@ -236,7 +237,7 @@ const props = defineProps({
236
237
  */
237
238
  editUrl: {
238
239
  default: undefined,
239
- type: Function as PropType<(row: CollectionItem) => string>,
240
+ type: Function as PropType<(row: CollectionItem) => RouteLocationRaw>,
240
241
  },
241
242
 
242
243
  /**
@@ -1,16 +1,7 @@
1
1
  import BaseShortcut from './BaseShortcut.vue';
2
+ import { palette } from '@/utils/colors';
2
3
 
3
- const colors = [
4
- 'gray',
5
- 'red',
6
- 'orange',
7
- 'yellow',
8
- 'green',
9
- 'blue',
10
- 'indigo',
11
- 'purple',
12
- 'pink',
13
- ];
4
+ const colors = [...Object.keys(palette), '#ff0000', '#dbeafe'];
14
5
 
15
6
  const sizes = ['base', 'lg'];
16
7
 
@@ -5,7 +5,7 @@
5
5
  <!-- Icon -->
6
6
  <div
7
7
  class="mb-2.5 inline-flex items-center rounded p-2"
8
- :class="[colorClasses]"
8
+ :style="colorStyle"
9
9
  >
10
10
  <BaseIcon
11
11
  v-if="icon"
@@ -47,6 +47,7 @@ import { PropType } from 'vue';
47
47
  import { BaseIcon } from '.';
48
48
  import BaseCard from './BaseCard.vue';
49
49
  import { RouteLocationRaw } from 'vue-router';
50
+ import { getColorConfig } from '@/utils/colors';
50
51
 
51
52
  const props = defineProps({
52
53
  to: {
@@ -67,17 +68,7 @@ const props = defineProps({
67
68
  },
68
69
  color: {
69
70
  default: 'gray',
70
- type: String as PropType<
71
- | 'gray'
72
- | 'red'
73
- | 'orange'
74
- | 'yellow'
75
- | 'green'
76
- | 'blue'
77
- | 'indigo'
78
- | 'purple'
79
- | 'pink'
80
- >,
71
+ type: String as PropType<string>,
81
72
  },
82
73
  icon: {
83
74
  required: true,
@@ -89,62 +80,14 @@ const props = defineProps({
89
80
  },
90
81
  });
91
82
 
92
- const colorClasses = computed(() => {
93
- if (props.color == 'gray') {
94
- if (props.contrast == 'high') {
95
- return 'bg-slate-600 text-white';
96
- }
97
- return 'bg-slate-100 text-slate-800 border border-slate-300';
98
- }
99
- if (props.color == 'red') {
100
- if (props.contrast == 'high') {
101
- return 'bg-red-600 text-white';
102
- }
103
- return 'bg-red-100 text-red-700 border border-red-300';
104
- }
105
- if (props.color == 'orange') {
106
- if (props.contrast == 'high') {
107
- return 'bg-orange-500 text-white';
108
- }
109
- return 'bg-orange-100 text-yellow-700 border border-orange-300';
110
- }
111
- if (props.color == 'yellow') {
112
- if (props.contrast == 'high') {
113
- return 'bg-yellow-500 text-white';
114
- }
115
- return 'bg-yellow-100 text-yellow-700 border border-yellow-300';
116
- }
117
- if (props.color == 'green') {
118
- if (props.contrast == 'high') {
119
- return 'bg-green-600 text-white';
120
- }
121
- return 'bg-green-100 text-green-700 border border-green-300';
122
- }
123
- if (props.color == 'blue') {
124
- if (props.contrast == 'high') {
125
- return 'bg-blue-600 text-white';
126
- }
127
- return 'bg-blue-100 text-blue-700 border border-blue-300';
128
- }
129
- if (props.color == 'indigo') {
130
- if (props.contrast == 'high') {
131
- return 'bg-indigo-600 text-white';
132
- }
133
- return 'bg-indigo-100 text-indigo-700 border border-indigo-300';
134
- }
135
- if (props.color == 'purple') {
136
- if (props.contrast == 'high') {
137
- return 'bg-purple-600 text-white';
138
- }
139
- return 'bg-purple-100 text-purple-700 border border-purple-300';
140
- }
141
- if (props.color == 'pink') {
142
- if (props.contrast == 'high') {
143
- return 'bg-pink-600 text-white';
144
- }
145
- return 'bg-pink-100 text-pink-700 border border-pink-300';
146
- }
147
- return 'bg-slate-100 text-slate-700 border border-slate-300';
83
+ const colorStyle = computed((): Record<string, string> => {
84
+ const config = getColorConfig(props.color, props.contrast == 'high');
85
+
86
+ return {
87
+ backgroundColor: config.backgroundColor,
88
+ border: `1px solid ${config.borderColor}`,
89
+ color: config.textColor,
90
+ };
148
91
  });
149
92
 
150
93
  const iconSizeClasses = computed(() => {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="relative isolate overflow-hidden rounded" :class="[background]">
3
3
  <div
4
- class="animate-shimmer absolute inset-0 -translate-x-full border-t border-white/80 bg-gradient-to-r from-transparent via-white/80 to-transparent"
4
+ class="absolute inset-0 -translate-x-full animate-shimmer border-t border-white/80 bg-gradient-to-r from-transparent via-white/80 to-transparent"
5
5
  :style="{
6
6
  animationDelay: delay,
7
7
  }"