@energie360/ui-library 0.1.0 → 0.1.2
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/base/_input-resets.scss +9 -3
- package/base/_resets.scss +5 -0
- package/base/abstracts/_mixins.scss +11 -5
- package/base/main-base.scss +1 -0
- package/components/accordion-item/accordion-item.scss +62 -0
- package/components/accordion-item/u-accordion-item.vue +44 -0
- package/components/card/card.scss +58 -0
- package/components/card/u-card.vue +26 -0
- package/components/card-header/card-header.scss +102 -0
- package/components/card-header/u-card-header.vue +51 -0
- package/components/card-hint/card-hint.scss +13 -0
- package/components/card-hint/u-card-hint.vue +23 -0
- package/components/card-price/card-price.scss +110 -0
- package/components/card-price/u-card-price.vue +47 -0
- package/components/card-table/card-table.scss +76 -0
- package/components/card-table/u-card-table.vue +77 -0
- package/components/card-toggle-switches/card-toggle-switches.scss +13 -0
- package/components/card-toggle-switches/u-card-toggle-switches.vue +30 -0
- package/components/collapsible/collapsible.scss +14 -0
- package/components/collapsible/u-collapsible.vue +81 -0
- package/components/collapsible-group/u-collapsible-group.vue +14 -0
- package/components/icon-teaser/icon-teaser.scss +58 -0
- package/components/icon-teaser/u-icon-teaser.vue +35 -0
- package/components/icon-teaser-group/icon-teaser-group.scss +10 -0
- package/components/icon-teaser-group/u-icon-teaser-group.vue +19 -0
- package/components/icon-text-block/{icon-text-block.vue → u-icon-text-block.vue} +11 -12
- package/components/index.js +14 -0
- package/components/language-nav/language-nav.scss +32 -0
- package/components/language-nav/u-language-nav.vue +27 -0
- package/components/panel/panel.scss +107 -0
- package/components/panel/u-panel.vue +48 -0
- package/components/progress-bar/progress-bar.scss +37 -0
- package/components/progress-bar/u-progress-bar.vue +21 -0
- package/components/richtext/richtext.scss +208 -0
- package/components/richtext/u-richtext.vue +21 -0
- package/components/table/cell-ctas.scss +12 -0
- package/components/table/cell-icon-group.scss +12 -0
- package/components/table/cell-icon-text.scss +22 -0
- package/components/table/cell-progress-bar.scss +23 -0
- package/components/table/table-cell.mixins.scss +60 -0
- package/components/table/table-cell.scss +24 -0
- package/components/table/table-header.scss +5 -0
- package/components/table/table-heading.scss +8 -0
- package/components/table/table-row.scss +20 -0
- package/components/table/table.scss +12 -0
- package/components/table/table.type.ts +31 -0
- package/components/table/u-cell-ctas.vue +28 -0
- package/components/table/u-cell-icon-group.vue +31 -0
- package/components/table/u-cell-icon-text.vue +23 -0
- package/components/table/u-cell-progress-bar.vue +22 -0
- package/components/table/u-table-cell.vue +37 -0
- package/components/table/u-table-header.vue +9 -0
- package/components/table/u-table-heading.vue +21 -0
- package/components/table/u-table-row.vue +17 -0
- package/components/table/u-table.vue +11 -0
- package/components/tooltip/dom.js +167 -0
- package/components/tooltip/popover.ts +208 -0
- package/components/tooltip/tooltip.scss +75 -0
- package/components/tooltip/u-tooltip.vue +72 -0
- package/components/tooltip/viewport.js +21 -0
- package/custom-elements.js +1 -0
- package/dist/base-style.css +409 -2
- package/dist/base-style.css.map +1 -0
- package/dist/elements/text-link.css +40 -0
- package/dist/elements/text-link.css.map +1 -0
- package/dist/layout/split.css +124 -0
- package/dist/layout/split.css.map +1 -0
- package/elements/button/_button-base.scss +1 -1
- package/elements/button/_button-filled-inverted.scss +3 -3
- package/elements/button/_button-filled.scss +3 -3
- package/elements/button/_button-outlined-inverted.scss +3 -3
- package/elements/button/_button-outlined.scss +3 -3
- package/elements/button/_button-plain.scss +3 -3
- package/elements/button/_button-secondary-outlined.scss +3 -3
- package/elements/button/button.js +2 -2
- package/elements/button/button.scss +1 -1
- package/elements/button/u-button.vue +41 -0
- package/elements/button-chip/button-chip.scss +83 -0
- package/elements/button-chip/u-button-chip.vue +45 -0
- package/elements/elements.js +35 -0
- package/elements/form-field/form-field-base.scss +141 -0
- package/elements/form-field/form-field-error.scss +20 -0
- package/elements/form-field/form-field-prefix-suffix.scss +80 -0
- package/elements/form-field/form-field-states.scss +59 -0
- package/elements/form-field/form-field.types.ts +8 -0
- package/elements/form-field/index.scss +4 -0
- package/elements/icon/icon.js +2 -2
- package/elements/icon/{icon.vue → u-icon.vue} +12 -18
- package/elements/icon-button/icon-button.js +2 -2
- package/elements/icon-button/{icon-button.vue → u-icon-button.vue} +14 -15
- package/elements/image/image.scss +3 -0
- package/elements/image/u-image.vue +17 -0
- package/elements/index.js +6 -31
- package/elements/loader/loader.js +2 -2
- package/elements/loader/{loader.vue → u-loader.vue} +6 -7
- package/elements/numeric-stepper/numeric-stepper.scss +110 -0
- package/elements/numeric-stepper/u-numeric-stepper.vue +135 -0
- package/elements/select/select.scss +32 -0
- package/elements/select/u-select.vue +130 -0
- package/elements/select-chip/select-chip.scss +18 -0
- package/elements/select-chip/u-select-chip.vue +50 -0
- package/elements/select-chips/select-chips.scss +5 -0
- package/elements/select-chips/u-select-chips.vue +23 -0
- package/elements/spectro/spectro.scss +10 -0
- package/elements/spectro/u-spectro.vue +11 -0
- package/elements/text-field/text-field.scss +30 -0
- package/elements/text-field/text-field.types.ts +6 -0
- package/elements/text-field/u-text-field.vue +180 -0
- package/elements/text-link/text-link.scss +57 -0
- package/elements/toggle-switch/toggle-switch-small.scss +40 -0
- package/elements/toggle-switch/toggle-switch.scss +149 -0
- package/elements/toggle-switch/u-toggle-switch.vue +68 -0
- package/elements/types.ts +19 -0
- package/env.d.ts +1 -0
- package/globals.js +1 -2
- package/helpers/transition-height.vue +39 -0
- package/i18n/i18n.ts +40 -0
- package/layout/grid/grid.mixin.scss +4 -11
- package/layout/grid/grid.scss +6 -7
- package/layout/split/split.scss +96 -0
- package/modules/footer/footer.scss +161 -0
- package/modules/footer/u-footer.vue +59 -0
- package/package.json +33 -13
- package/tsconfig.app.json +12 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +19 -0
- package/utility/elements/text-link.scss +1 -0
- package/utility/layout/split.scss +1 -0
- package/utility/utility-text.js +1 -0
- package/utils/object/deep-get.js +1 -2
- package/utils/translations/translate.js +13 -0
- package/{vite.config.js → vite.config.ts} +2 -1
- package/watch.js +27 -0
- package/wizard/index.js +4 -0
- package/wizard/wizard-intro/{wizard-intro.vue → u-wizard-intro.vue} +12 -9
- package/wizard/wizard-intro/wizard-intro.scss +4 -0
- package/wizard/wizard-layout/{wizard-layout-block.vue → u-wizard-layout-block.vue} +7 -5
- package/wizard/wizard-layout/{wizard-layout-element.vue → u-wizard-layout-element.vue} +1 -1
- package/wizard/wizard-layout/{wizard-layout.vue → u-wizard-layout.vue} +1 -1
- package/wizard/wizard-layout/wizard-layout.scss +6 -6
- package/dist/base-style.js +0 -2
- package/dist/base-style.js.map +0 -1
- package/dist/index.css +0 -1
- package/dist/index.js +0 -5194
- package/dist/index.js.map +0 -1
- package/elements/button/button.vue +0 -42
- package/index.js +0 -1
- /package/components/icon-text-block-group/{icon-text-block-group.vue → u-icon-text-block-group.vue} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
@use '../../base/abstracts' as a;
|
|
2
|
+
@use '../form-field' as f;
|
|
3
|
+
|
|
4
|
+
.text-field {
|
|
5
|
+
@include f.form-field-base(input);
|
|
6
|
+
@include f.form-field-states-all(input);
|
|
7
|
+
@include f.form-field-error;
|
|
8
|
+
@include f.form-field-suffix-icon;
|
|
9
|
+
@include f.form-field-prefix-icon;
|
|
10
|
+
|
|
11
|
+
.visually-hidden {
|
|
12
|
+
@include a.visually-hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Type: Password
|
|
16
|
+
.password-toggle {
|
|
17
|
+
display: block;
|
|
18
|
+
border-radius: var(--e-brd-radius-1);
|
|
19
|
+
color: var(--e-c-primary-01-500);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
|
|
22
|
+
&:hover {
|
|
23
|
+
color: var(--e-c-secondary-01-900);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:active {
|
|
27
|
+
color: var(--e-c-secondary-01-700);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import UIcon from '../icon/u-icon.vue'
|
|
3
|
+
import { TextFieldTypes } from './text-field.types'
|
|
4
|
+
import { computed, ref, useSlots, useTemplateRef, useId, watch } from 'vue'
|
|
5
|
+
import { FormFieldBase } from '../form-field/form-field.types'
|
|
6
|
+
import { getTranslation } from '../../utils/translations/translate'
|
|
7
|
+
|
|
8
|
+
interface Props extends FormFieldBase {
|
|
9
|
+
name: string
|
|
10
|
+
type?: TextFieldTypes
|
|
11
|
+
placeholder?: string
|
|
12
|
+
readonly?: boolean
|
|
13
|
+
unit?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const inputId = useId()
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
disabled = false,
|
|
20
|
+
readonly = false,
|
|
21
|
+
required = false,
|
|
22
|
+
type = TextFieldTypes.text,
|
|
23
|
+
helpText = '',
|
|
24
|
+
errorMessage = '',
|
|
25
|
+
} = defineProps<Props>()
|
|
26
|
+
|
|
27
|
+
const slots = useSlots()
|
|
28
|
+
const model = defineModel<string>()
|
|
29
|
+
|
|
30
|
+
const input = useTemplateRef('input')
|
|
31
|
+
|
|
32
|
+
const isFocused = ref(false)
|
|
33
|
+
const isHovering = ref(false)
|
|
34
|
+
const hasValue = ref(false) // only needed for input type 'search'
|
|
35
|
+
const forceFloatLabel = ref(false)
|
|
36
|
+
|
|
37
|
+
const spacer = '. '
|
|
38
|
+
|
|
39
|
+
// In some cases we need to change the input type within the component (for example for the password-show behaviour)
|
|
40
|
+
const _inputType = ref(type)
|
|
41
|
+
|
|
42
|
+
const onFocus = () => {
|
|
43
|
+
if (readonly || disabled) {
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
isFocused.value = true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const onBlur = () => {
|
|
51
|
+
isFocused.value = false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const onInput = () => {
|
|
55
|
+
hasValue.value = !!input.value && input.value.value !== ''
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const onHover = () => {
|
|
59
|
+
if (readonly || disabled) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
isHovering.value = true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const onHoverOut = () => {
|
|
67
|
+
isHovering.value = false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const hasHelpText = computed(() => {
|
|
71
|
+
return !!helpText || !!slots.helpText || required
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const needsHelpTextSpacer = computed(() => {
|
|
75
|
+
return !!helpText || !!slots.helpText
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const onPasswordToggle = () => {
|
|
79
|
+
_inputType.value =
|
|
80
|
+
_inputType.value === TextFieldTypes.password ? TextFieldTypes.text : TextFieldTypes.password
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const passwordIcon = computed(() => {
|
|
84
|
+
return _inputType.value === TextFieldTypes.password ? 'password' : 'password-show'
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
const passwordA11yText = computed(() => {
|
|
88
|
+
return _inputType.value === TextFieldTypes.password ? 'showPassword' : 'hidePassword'
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
watch(
|
|
92
|
+
() => type,
|
|
93
|
+
() => {
|
|
94
|
+
if (type === TextFieldTypes.password) {
|
|
95
|
+
_inputType.value = TextFieldTypes.password
|
|
96
|
+
} else {
|
|
97
|
+
_inputType.value = type
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<template>
|
|
104
|
+
<div
|
|
105
|
+
:class="[
|
|
106
|
+
'text-field',
|
|
107
|
+
{
|
|
108
|
+
required,
|
|
109
|
+
disabled,
|
|
110
|
+
readonly,
|
|
111
|
+
focus: isFocused,
|
|
112
|
+
hover: isHovering,
|
|
113
|
+
'has-value': hasValue,
|
|
114
|
+
'float-label': isFocused || hasValue || placeholder || forceFloatLabel,
|
|
115
|
+
'has-error': error,
|
|
116
|
+
'show-help-text': !required || hasHelpText,
|
|
117
|
+
},
|
|
118
|
+
]"
|
|
119
|
+
@mouseenter="onHover"
|
|
120
|
+
@mouseleave="onHoverOut"
|
|
121
|
+
>
|
|
122
|
+
<div class="wrapper">
|
|
123
|
+
<div class="label">
|
|
124
|
+
<slot name="label"
|
|
125
|
+
><label :for="inputId">{{ label }}</label></slot
|
|
126
|
+
>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
<div class="control">
|
|
130
|
+
<slot
|
|
131
|
+
><input
|
|
132
|
+
:id="inputId"
|
|
133
|
+
ref="input"
|
|
134
|
+
v-model="model"
|
|
135
|
+
:name
|
|
136
|
+
:type="_inputType"
|
|
137
|
+
:disabled
|
|
138
|
+
:readonly
|
|
139
|
+
:placeholder
|
|
140
|
+
:required
|
|
141
|
+
@input="onInput"
|
|
142
|
+
@focus="onFocus"
|
|
143
|
+
@blur="onBlur"
|
|
144
|
+
/></slot>
|
|
145
|
+
|
|
146
|
+
<div class="control-border"></div>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<!-- TYPE: PASSWORD -->
|
|
150
|
+
<span v-if="type === TextFieldTypes.password" class="suffix-action">
|
|
151
|
+
<button type="button" class="password-toggle" @click="onPasswordToggle">
|
|
152
|
+
<span class="visually-hidden">{{ getTranslation(passwordA11yText) }}</span>
|
|
153
|
+
<UIcon :name="passwordIcon"></UIcon>
|
|
154
|
+
</button>
|
|
155
|
+
</span>
|
|
156
|
+
|
|
157
|
+
<!-- UNIT -->
|
|
158
|
+
<span v-if="unit" class="suffix-text">
|
|
159
|
+
{{ unit }}
|
|
160
|
+
</span>
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<div class="help-text">
|
|
164
|
+
<span class="optional-text"
|
|
165
|
+
>{{ getTranslation('optional')
|
|
166
|
+
}}<span v-if="needsHelpTextSpacer" v-html="spacer"></span></span
|
|
167
|
+
><slot name="helpText">{{ helpText }}</slot>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div class="error-messages-container">
|
|
171
|
+
<slot name="error-message"
|
|
172
|
+
><span>{{ errorMessage }}</span></slot
|
|
173
|
+
>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</template>
|
|
177
|
+
|
|
178
|
+
<style scoped lang="scss">
|
|
179
|
+
@use './text-field.scss';
|
|
180
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@use '../../base/abstracts' as a;
|
|
2
|
+
|
|
3
|
+
@mixin text-link {
|
|
4
|
+
@include a.type(200, strong);
|
|
5
|
+
|
|
6
|
+
color: var(--e-c-primary-01-700);
|
|
7
|
+
text-decoration: underline;
|
|
8
|
+
text-underline-offset: 0.4em;
|
|
9
|
+
transition:
|
|
10
|
+
text-decoration-color a.$trs-default,
|
|
11
|
+
color a.$trs-default;
|
|
12
|
+
|
|
13
|
+
&:hover {
|
|
14
|
+
text-decoration-color: var(--e-c-primary-01-50);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&:active {
|
|
18
|
+
text-decoration-color: var(--e-c-primary-01-700);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@mixin text-link--inverted {
|
|
23
|
+
color: var(--e-c-primary-01-50);
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
text-decoration-color: var(--e-c-primary-01-200);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:active {
|
|
30
|
+
text-decoration-color: var(--e-c-primary-01-50);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@mixin text-link--secondary {
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
color: var(--e-c-mono-700);
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
color: var(--e-c-mono-900);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:active {
|
|
43
|
+
color: var(--e-c-mono-700);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.text-link {
|
|
48
|
+
@include text-link;
|
|
49
|
+
|
|
50
|
+
&.inverted {
|
|
51
|
+
@include text-link--inverted;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.secondary {
|
|
55
|
+
@include text-link--secondary;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@use '../../base/abstracts' as a;
|
|
2
|
+
|
|
3
|
+
.toggle-switch.toggle-switch--small {
|
|
4
|
+
--width: 54px;
|
|
5
|
+
--height: 28px;
|
|
6
|
+
--handle-size: 24px;
|
|
7
|
+
--inner-padding: 2px;
|
|
8
|
+
|
|
9
|
+
.toggle-switch__wrapper {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
width: 100%;
|
|
13
|
+
gap: var(--e-space-4);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.toggle-switch__handle {
|
|
17
|
+
padding: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.toggle-switch__text {
|
|
21
|
+
@include a.visually-hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toggle-switch__label {
|
|
25
|
+
@include a.type(200);
|
|
26
|
+
|
|
27
|
+
padding-top: var(--e-space-0_5);
|
|
28
|
+
padding-bottom: var(--e-space-0_5);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.label-left {
|
|
32
|
+
.toggle-switch__wrapper {
|
|
33
|
+
flex-direction: row-reverse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.toggle-switch__label {
|
|
37
|
+
margin-right: auto;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
@use '../../base/abstracts/' as a;
|
|
2
|
+
@use './toggle-switch-small';
|
|
3
|
+
|
|
4
|
+
.toggle-switch {
|
|
5
|
+
--width: 102px;
|
|
6
|
+
--height: 48px;
|
|
7
|
+
--handle-size: 40px;
|
|
8
|
+
--inner-padding: 4px;
|
|
9
|
+
|
|
10
|
+
.toggle-switch__wrapper {
|
|
11
|
+
display: block;
|
|
12
|
+
position: relative;
|
|
13
|
+
width: var(--width);
|
|
14
|
+
min-height: var(--height);
|
|
15
|
+
|
|
16
|
+
input {
|
|
17
|
+
// So that the focus works nicely.
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.toggle-switch__toggle {
|
|
24
|
+
display: flex;
|
|
25
|
+
width: var(--width);
|
|
26
|
+
height: var(--height);
|
|
27
|
+
flex: 0 0 auto;
|
|
28
|
+
align-items: center;
|
|
29
|
+
position: relative;
|
|
30
|
+
background-color: var(--e-c-mono-200);
|
|
31
|
+
border-radius: calc(var(--height) * 0.5);
|
|
32
|
+
transition: background-color var(--e-trs-duration-faster) var(--e-trs-easing-default);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.toggle-switch__handle {
|
|
36
|
+
position: absolute;
|
|
37
|
+
padding: a.rem(8);
|
|
38
|
+
background-color: var(--e-c-mono-00);
|
|
39
|
+
border-radius: 100%;
|
|
40
|
+
width: var(--handle-size);
|
|
41
|
+
height: var(--handle-size);
|
|
42
|
+
top: var(--inner-padding);
|
|
43
|
+
left: var(--inner-padding);
|
|
44
|
+
pointer-events: none;
|
|
45
|
+
color: var(--e-c-mono-900);
|
|
46
|
+
transition:
|
|
47
|
+
transform var(--e-trs-duration-faster) var(--e-trs-easing-default),
|
|
48
|
+
color var(--e-trs-duration-faster) var(--e-trs-easing-default);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.toggle-switch__text {
|
|
52
|
+
@include a.type(200, strong);
|
|
53
|
+
|
|
54
|
+
display: block;
|
|
55
|
+
position: absolute;
|
|
56
|
+
padding-left: a.rem(8);
|
|
57
|
+
padding-right: a.rem(8);
|
|
58
|
+
transition:
|
|
59
|
+
color var(--e-trs-duration-faster) var(--e-trs-easing-default),
|
|
60
|
+
opacity var(--e-trs-duration-faster) var(--e-trs-easing-default);
|
|
61
|
+
|
|
62
|
+
&.yes {
|
|
63
|
+
left: 16px;
|
|
64
|
+
opacity: 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&.no {
|
|
68
|
+
right: 10px;
|
|
69
|
+
opacity: 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
.toggle-switch__toggle {
|
|
75
|
+
background-color: var(--e-c-mono-500);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&:active {
|
|
80
|
+
.toggle-switch__toggle {
|
|
81
|
+
background-color: var(--e-c-mono-700);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.toggle-switch__text {
|
|
85
|
+
color: var(--e-c-mono-00);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// States
|
|
90
|
+
&.checked {
|
|
91
|
+
.toggle-switch__toggle {
|
|
92
|
+
background-color: var(--e-c-primary-01-900);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.toggle-switch__handle {
|
|
96
|
+
transform: translateX(calc(var(--width) - var(--handle-size) - var(--inner-padding) * 2));
|
|
97
|
+
color: var(--e-c-primary-01-900);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.toggle-switch__text {
|
|
101
|
+
color: var(--e-c-mono-00);
|
|
102
|
+
|
|
103
|
+
&.yes {
|
|
104
|
+
opacity: 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.no {
|
|
108
|
+
opacity: 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&:hover {
|
|
113
|
+
.toggle-switch__toggle {
|
|
114
|
+
background-color: var(--e-c-secondary-01-900);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.toggle-switch__handle {
|
|
118
|
+
color: var(--e-c-secondary-01-900);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&:active {
|
|
123
|
+
.toggle-switch__toggle {
|
|
124
|
+
background-color: var(--e-c-secondary-01-700);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.toggle-switch__handle {
|
|
128
|
+
color: var(--e-c-secondary-01-700);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&.disabled,
|
|
134
|
+
&.disabled.checked {
|
|
135
|
+
.toggle-switch__handle,
|
|
136
|
+
.toggle-switch__text {
|
|
137
|
+
color: var(--e-c-mono-500);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.toggle-switch__toggle {
|
|
141
|
+
background-color: var(--e-c-mono-50);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// // TODO: Do we need readonly styles here?
|
|
146
|
+
// &.readonly {
|
|
147
|
+
// //
|
|
148
|
+
// }
|
|
149
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import UIcon from '../icon/u-icon.vue'
|
|
4
|
+
import { getTranslation } from '../../utils/translations/translate'
|
|
5
|
+
|
|
6
|
+
export interface ToggleSwitch {
|
|
7
|
+
name: string
|
|
8
|
+
label?: string
|
|
9
|
+
required?: boolean
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
readonly?: boolean
|
|
12
|
+
value?: string
|
|
13
|
+
variant?: 'normal' | 'small'
|
|
14
|
+
labelPosition?: 'left' | 'right'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
variant = 'big',
|
|
19
|
+
labelPosition = 'right',
|
|
20
|
+
disabled = false,
|
|
21
|
+
readonly = false,
|
|
22
|
+
required = false,
|
|
23
|
+
} = defineProps<ToggleSwitch>()
|
|
24
|
+
|
|
25
|
+
const model = defineModel<boolean>({ default: false })
|
|
26
|
+
|
|
27
|
+
const iconsMap = {
|
|
28
|
+
small: ['close-small', 'check-small'],
|
|
29
|
+
big: ['close', 'mini-check'],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const uncheckIcon = computed(() => iconsMap[variant][0])
|
|
33
|
+
const checkIcon = computed(() => iconsMap[variant][1])
|
|
34
|
+
|
|
35
|
+
const classes = computed(() => ({
|
|
36
|
+
checked: model.value,
|
|
37
|
+
disabled,
|
|
38
|
+
readonly,
|
|
39
|
+
[`toggle-switch--${variant}`]: variant,
|
|
40
|
+
[`label-${labelPosition}`]: labelPosition,
|
|
41
|
+
}))
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div :class="['toggle-switch', classes]">
|
|
46
|
+
<label class="toggle-switch__wrapper">
|
|
47
|
+
<span class="toggle-switch__toggle">
|
|
48
|
+
<span class="toggle-switch__text yes" :aria-hidden="model.value ? 'false' : 'true'">{{
|
|
49
|
+
getTranslation('yes')
|
|
50
|
+
}}</span>
|
|
51
|
+
<span class="toggle-switch__text no" :aria-hidden="model.value ? 'true' : 'false'">{{
|
|
52
|
+
getTranslation('no')
|
|
53
|
+
}}</span>
|
|
54
|
+
<span class="toggle-switch__handle">
|
|
55
|
+
<UIcon :name="model.value ? checkIcon : uncheckIcon" custom-size />
|
|
56
|
+
</span>
|
|
57
|
+
</span>
|
|
58
|
+
{{ label }}
|
|
59
|
+
<slot name="input"
|
|
60
|
+
><input v-model="model" type="checkbox" :name :required :disabled :readonly :value
|
|
61
|
+
/></slot>
|
|
62
|
+
</label>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<style lang="scss">
|
|
67
|
+
@use './toggle-switch.scss';
|
|
68
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// TODO: @Dani if you have a better naming please update it.
|
|
2
|
+
|
|
3
|
+
export interface Cta {
|
|
4
|
+
label: string
|
|
5
|
+
href: string
|
|
6
|
+
target: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Image {
|
|
10
|
+
src: string
|
|
11
|
+
alt: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SelectOption {
|
|
15
|
+
label: string
|
|
16
|
+
value: string | number
|
|
17
|
+
disabled?: boolean
|
|
18
|
+
selected?: boolean
|
|
19
|
+
}
|
package/env.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/globals.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
// A possible idea would be to use a cdn when the package is built.
|
|
2
2
|
// Currently we'll use a fixed path for the assets on dev and prod. This must be made available by the application using ui-library.
|
|
3
|
-
export const assetsPath =
|
|
4
|
-
import.meta.env.DEV === true ? '/static/ui-assets/' : '/static/ui-assets/'
|
|
3
|
+
export const assetsPath = import.meta.env.DEV === true ? '/static/ui-assets/' : '/static/ui-assets/'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const onEnter = (el) => {
|
|
3
|
+
el.hidden = false
|
|
4
|
+
el.style.height = `${el.scrollHeight}px`
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const onAfterEnter = (el) => {
|
|
8
|
+
el.style.height = 'auto'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const onLeave = (el) => {
|
|
12
|
+
el.style.height = `${el.scrollHeight}px`
|
|
13
|
+
|
|
14
|
+
requestAnimationFrame(() => {
|
|
15
|
+
el.style.height = '0'
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<Transition name="fade" @enter="onEnter" @after-enter="onAfterEnter" @leave="onLeave">
|
|
22
|
+
<slot></slot>
|
|
23
|
+
</Transition>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<style scoped lang="scss">
|
|
27
|
+
@use '../base/abstracts' as a;
|
|
28
|
+
|
|
29
|
+
.fade-enter-active,
|
|
30
|
+
.fade-leave-active {
|
|
31
|
+
transition: height a.$trs-default;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.fade-enter-from,
|
|
36
|
+
.fade-leave-to {
|
|
37
|
+
height: 0;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
package/i18n/i18n.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const translations = {
|
|
2
|
+
DE: {
|
|
3
|
+
yes: 'Ja',
|
|
4
|
+
no: 'Nein',
|
|
5
|
+
optional: 'Optional',
|
|
6
|
+
increaseValue: 'Wert erhöhen',
|
|
7
|
+
decreaseValue: 'Wert vermindern',
|
|
8
|
+
showPassword: 'Passwort anzeigen',
|
|
9
|
+
hidePassword: 'Passwort verbergen',
|
|
10
|
+
},
|
|
11
|
+
FR: {
|
|
12
|
+
yes: 'Ja',
|
|
13
|
+
no: 'Nein',
|
|
14
|
+
optional: 'Optional',
|
|
15
|
+
increaseValue: 'Wert erhöhen',
|
|
16
|
+
decreaseValue: 'Wert vermindern',
|
|
17
|
+
showPassword: 'Passwort anzeigen',
|
|
18
|
+
hidePassword: 'Passwort verbergen',
|
|
19
|
+
},
|
|
20
|
+
IT: {
|
|
21
|
+
yes: 'Ja',
|
|
22
|
+
no: 'Nein',
|
|
23
|
+
optional: 'Optional',
|
|
24
|
+
increaseValue: 'Wert erhöhen',
|
|
25
|
+
decreaseValue: 'Wert vermindern',
|
|
26
|
+
showPassword: 'Passwort anzeigen',
|
|
27
|
+
hidePassword: 'Passwort verbergen',
|
|
28
|
+
},
|
|
29
|
+
EN: {
|
|
30
|
+
yes: 'Ja',
|
|
31
|
+
no: 'Nein',
|
|
32
|
+
optional: 'Optional',
|
|
33
|
+
increaseValue: 'Wert erhöhen',
|
|
34
|
+
decreaseValue: 'Wert vermindern',
|
|
35
|
+
showPassword: 'Passwort anzeigen',
|
|
36
|
+
hidePassword: 'Passwort verbergen',
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default translations
|
|
@@ -6,8 +6,7 @@ Helper to colculate col width in %.
|
|
|
6
6
|
Looks complicated because we use grid-gap on the row, which takes away from available width.
|
|
7
7
|
*/
|
|
8
8
|
@function col-width($size, $columns, $gutter) {
|
|
9
|
-
@return math.div(100% - (($columns - 1) * $gutter), $columns) * $size +
|
|
10
|
-
(($size - 1) * $gutter);
|
|
9
|
+
@return math.div(100% - (($columns - 1) * $gutter), $columns) * $size + (($size - 1) * $gutter);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
@mixin grid-row() {
|
|
@@ -63,17 +62,11 @@ $columns: Grid size (in columns). Default is set by global variable $grid-column
|
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
// TODO: Change args order -> $prop, $indent, $columns
|
|
66
|
-
@mixin grid-col-space(
|
|
67
|
-
$indent,
|
|
68
|
-
$columns: a.$grid-columns,
|
|
69
|
-
$prop: 'margin-left'
|
|
70
|
-
) {
|
|
71
|
-
#{$prop}: col-width($indent, $columns, a.$grid-gutter-2xl) +
|
|
72
|
-
a.$grid-gutter-2xl;
|
|
65
|
+
@mixin grid-col-space($indent, $columns: a.$grid-columns, $prop: 'margin-left') {
|
|
66
|
+
#{$prop}: col-width($indent, $columns, a.$grid-gutter-2xl) + a.$grid-gutter-2xl;
|
|
73
67
|
|
|
74
68
|
@include a.bp(lg) {
|
|
75
|
-
#{$prop}: col-width($indent, $columns, a.$grid-gutter-lg) +
|
|
76
|
-
a.$grid-gutter-lg;
|
|
69
|
+
#{$prop}: col-width($indent, $columns, a.$grid-gutter-lg) + a.$grid-gutter-lg;
|
|
77
70
|
}
|
|
78
71
|
|
|
79
72
|
@include a.bp(m) {
|