@globalbrain/sefirot 2.6.0 → 2.7.1

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.
@@ -3,13 +3,21 @@ import { computed } from 'vue'
3
3
  import SIcon from './SIcon.vue'
4
4
  import SLink from './SLink.vue'
5
5
 
6
+ export type Color =
7
+ | 'neutral'
8
+ | 'soft'
9
+ | 'mute'
10
+ | 'info'
11
+ | 'warning'
12
+ | 'danger'
13
+
6
14
  const props = defineProps<{
7
15
  value?: any
8
16
  record: any
9
17
  icon?: any
10
18
  getter?: string | ((value: any) => string)
11
- color?: 'neutral' | 'soft' | 'mute'
12
- iconColor?: 'neutral' | 'soft' | 'mute'
19
+ color?: Color | ((value: any, record: any) => Color)
20
+ iconColor?: Color | ((value: any, record: any) => Color)
13
21
  link?(value: any, record: any): string
14
22
  }>()
15
23
 
@@ -22,15 +30,27 @@ const _value = computed(() => {
22
30
  ? props.getter
23
31
  : props.getter(props.value)
24
32
  })
33
+
34
+ const _color = computed(() => {
35
+ return typeof props.color === 'function'
36
+ ? props.color(props.value, props.record)
37
+ : props.color ?? 'neutral'
38
+ })
39
+
40
+ const _iconColor = computed(() => {
41
+ return typeof props.iconColor === 'function'
42
+ ? props.iconColor(props.value, props.record)
43
+ : props.iconColor ?? 'neutral'
44
+ })
25
45
  </script>
26
46
 
27
47
  <template>
28
- <div class="STableCellText" :class="[{ link }, color ?? 'neutral']">
48
+ <div class="STableCellText" :class="[{ link }, _color]">
29
49
  <SLink v-if="_value" class="container" :href="link?.(value, record)">
30
- <div v-if="icon" class="icon" :class="[iconColor ?? color ?? 'neutral']">
50
+ <div v-if="icon" class="icon" :class="[_iconColor ?? _color]">
31
51
  <SIcon :icon="icon" class="svg" />
32
52
  </div>
33
- <div class="text" :class="[color ?? 'neutral']">
53
+ <div class="text" :class="[_color]">
34
54
  {{ _value }}
35
55
  </div>
36
56
  </SLink>
@@ -39,13 +59,13 @@ const _value = computed(() => {
39
59
 
40
60
  <style scoped lang="postcss">
41
61
  .STableCellText {
42
- padding: 8px 16px;
43
62
  min-height: 40px;
44
63
  }
45
64
 
46
65
  .container {
47
66
  display: flex;
48
67
  gap: 4px;
68
+ padding: 8px 16px;
49
69
  }
50
70
 
51
71
  .text {
@@ -60,6 +80,9 @@ const _value = computed(() => {
60
80
  &.neutral { color: var(--c-text-1); }
61
81
  &.soft { color: var(--c-text-2); }
62
82
  &.mute { color: var(--c-text-3); }
83
+ &.info { color: var(--c-info); }
84
+ &.warning { color: var(--c-warning); }
85
+ &.danger { color: var(--c-danger); }
63
86
 
64
87
  .STableCellText.link & { color: var(--c-info); }
65
88
  .STableCellText.link:hover & { color: var(--c-info-dark); }
@@ -70,6 +93,12 @@ const _value = computed(() => {
70
93
  .STableCellText.link:hover &.soft { color: var(--c-info); }
71
94
  .STableCellText.link &.mute { color: var(--c-text-3); }
72
95
  .STableCellText.link:hover &.mute { color: var(--c-info); }
96
+ .STableCellText.link &.info { color: var(--c-info); }
97
+ .STableCellText.link:hover &.info { color: var(--c-info-dark); }
98
+ .STableCellText.link &.warning { color: var(--c-warning); }
99
+ .STableCellText.link:hover &.warning { color: var(--c-warning-darker); }
100
+ .STableCellText.link &.danger { color: var(--c-danger); }
101
+ .STableCellText.link:hover &.danger { color: var(--c-danger-dark); }
73
102
  }
74
103
 
75
104
  .icon {
@@ -95,6 +124,12 @@ const _value = computed(() => {
95
124
  .STableCellText.link:hover &.soft { color: var(--c-info); }
96
125
  .STableCellText.link &.mute { color: var(--c-text-3); }
97
126
  .STableCellText.link:hover &.mute { color: var(--c-info); }
127
+ .STableCellText.link &.info { color: var(--c-info); }
128
+ .STableCellText.link:hover &.info { color: var(--c-info-dark); }
129
+ .STableCellText.link &.warning { color: var(--c-warning); }
130
+ .STableCellText.link:hover &.warning { color: var(--c-warning-dark); }
131
+ .STableCellText.link &.danger { color: var(--c-danger); }
132
+ .STableCellText.link:hover &.danger { color: var(--c-danger-dark); }
98
133
  }
99
134
 
100
135
  .svg {
@@ -47,10 +47,18 @@ export interface TableCellText extends TableCellBase {
47
47
  icon?: any
48
48
  value?: string | ((value: any) => string)
49
49
  link?(value: any, record: any): string
50
- color?: 'neutral' | 'soft' | 'mute'
51
- iconColor?: 'neutral' | 'soft' | 'mute'
50
+ color?: TableCellTextColor | ((value: any, record: any) => TableCellTextColor)
51
+ iconColor?: TableCellTextColor | ((value: any, record: any) => TableCellTextColor)
52
52
  }
53
53
 
54
+ export type TableCellTextColor =
55
+ | 'neutral'
56
+ | 'soft'
57
+ | 'mute'
58
+ | 'info'
59
+ | 'warning'
60
+ | 'danger'
61
+
54
62
  export interface TableCellDay extends TableCellBase {
55
63
  type: 'day'
56
64
  format?: string
@@ -1,8 +1,11 @@
1
1
  import dayjs, { ConfigType, Dayjs } from 'dayjs'
2
+ import RelativeTime from 'dayjs/plugin/relativeTime'
2
3
 
3
4
  export type Day = Dayjs
4
5
  export type Input = ConfigType
5
6
 
6
- export function day(input: Input): Dayjs {
7
+ dayjs.extend(RelativeTime)
8
+
9
+ export function day(input?: Input): Dayjs {
7
10
  return dayjs(input)
8
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "Vue Components for Global Brain Design System.",
5
5
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
6
6
  "license": "MIT",
@@ -29,7 +29,6 @@
29
29
  "@vuelidate/validators": "^2.0.0",
30
30
  "@vueuse/core": "^9.3.0",
31
31
  "body-scroll-lock": "^4.0.0-beta.0",
32
- "dayjs": "^1.11.5",
33
32
  "fuse.js": "^6.6.2",
34
33
  "lodash-es": "^4.17.21",
35
34
  "markdown-it": "^13.0.1",
@@ -42,6 +41,9 @@
42
41
  "vue": "^3.2.40",
43
42
  "vue-router": "^4.1.5"
44
43
  },
44
+ "dependencies": {
45
+ "dayjs": "^1.11.5"
46
+ },
45
47
  "devDependencies": {
46
48
  "@globalbrain/eslint-config": "^1.0.0",
47
49
  "@histoire/plugin-vue": "^0.10.7",