@oicl/openbridge-webcomponents 0.0.9 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/.release-it.json +1 -1
- package/.storybook/preview.ts +0 -1
- package/CHANGELOG.md +53 -1
- package/__snapshots__/application-topbar--inactive.png +0 -0
- package/__snapshots__/button-button--raised-disabled.png +0 -0
- package/__snapshots__/input-slider--no-icons.png +0 -0
- package/__snapshots__/input-slider--no-value.png +0 -0
- package/__snapshots__/line-corner-line--primary.png +0 -0
- package/__snapshots__/line-example--air.png +0 -0
- package/__snapshots__/line-example--connector.png +0 -0
- package/__snapshots__/line-example--electric.png +0 -0
- package/__snapshots__/line-example--fluid.png +0 -0
- package/__snapshots__/line-horizontal-line--primary.png +0 -0
- package/__snapshots__/line-vertical-line--complex.png +0 -0
- package/__snapshots__/line-vertical-line--primary.png +0 -0
- package/custom-elements.json +628 -263
- package/dist/automation/corner-line/corner-line.d.ts +22 -0
- package/dist/automation/corner-line/corner-line.d.ts.map +1 -0
- package/dist/automation/corner-line/corner-line.js +161 -0
- package/dist/automation/corner-line/corner-line.js.map +1 -0
- package/dist/automation/horizontal-line/horizontal-line.d.ts +15 -0
- package/dist/automation/horizontal-line/horizontal-line.d.ts.map +1 -0
- package/dist/automation/horizontal-line/horizontal-line.js +110 -0
- package/dist/automation/horizontal-line/horizontal-line.js.map +1 -0
- package/dist/automation/index.d.ts +20 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +42 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/vertical-line/vertical-line.d.ts +15 -0
- package/dist/automation/vertical-line/vertical-line.d.ts.map +1 -0
- package/dist/automation/vertical-line/vertical-line.js +111 -0
- package/dist/automation/vertical-line/vertical-line.js.map +1 -0
- package/dist/components/brilliance-menu/brilliance-menu.d.ts.map +1 -1
- package/dist/components/brilliance-menu/brilliance-menu.js +2 -0
- package/dist/components/brilliance-menu/brilliance-menu.js.map +1 -1
- package/dist/components/slider/slider.css.js +20 -0
- package/dist/components/slider/slider.css.js.map +1 -1
- package/dist/components/slider/slider.d.ts +8 -0
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +44 -18
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/top-bar/top-bar.css.js +5 -1
- package/dist/components/top-bar/top-bar.css.js.map +1 -1
- package/dist/components/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/top-bar/top-bar.js +8 -8
- package/dist/components/top-bar/top-bar.js.map +1 -1
- package/package.json +18 -25
- package/src/automation/corner-line/corner-line.stories.ts +31 -0
- package/src/automation/corner-line/corner-line.ts +167 -0
- package/src/automation/horizontal-line/horizontal-line.stories.ts +28 -0
- package/src/automation/horizontal-line/horizontal-line.ts +100 -0
- package/src/automation/index.ts +41 -0
- package/src/automation/line.stories.ts +142 -0
- package/src/automation/vertical-line/vertical-line.stories.ts +71 -0
- package/src/automation/vertical-line/vertical-line.ts +104 -0
- package/src/components/brilliance-menu/brilliance-menu.ts +2 -0
- package/src/components/slider/slider.css +20 -0
- package/src/components/slider/slider.stories.ts +20 -1
- package/src/components/slider/slider.ts +43 -19
- package/src/components/top-bar/top-bar.css +4 -0
- package/src/components/top-bar/top-bar.ts +10 -8
- package/src/palettes/variables.css +64 -43
- package/script/svg-instruments/convert-svg.ts +0 -246
- package/script/svg-instruments/environment.d.ts +0 -7
- package/script/svg-instruments/exports.ts +0 -82
- package/script/svg-instruments/figma-types.ts +0 -804
- package/script/svg-instruments/figmaImport.ts +0 -79
- package/script/svg-instruments/main.ts +0 -109
@@ -0,0 +1,100 @@
|
|
1
|
+
import {LitElement, html, css} from 'lit';
|
2
|
+
import {customElement, property} from 'lit/decorators.js';
|
3
|
+
import {
|
4
|
+
LineMedium,
|
5
|
+
LineMediumType,
|
6
|
+
lineColor,
|
7
|
+
LineType,
|
8
|
+
LineTypeType,
|
9
|
+
lineWidth,
|
10
|
+
} from '../index';
|
11
|
+
|
12
|
+
@customElement('obc-horizontal-line')
|
13
|
+
export class ObcHorizontalLine extends LitElement {
|
14
|
+
@property({type: String}) medium: LineMediumType = LineMedium.normal;
|
15
|
+
@property({type: String, attribute: 'line-type'}) lineType: LineTypeType =
|
16
|
+
LineType.fluid;
|
17
|
+
@property({type: Number}) length: number = 1;
|
18
|
+
|
19
|
+
override render() {
|
20
|
+
if (this.lineType === LineType.connector) {
|
21
|
+
const length = this.length * 24;
|
22
|
+
return html`<svg
|
23
|
+
width="${length}"
|
24
|
+
height="24"
|
25
|
+
viewBox="0 0 ${length} 24"
|
26
|
+
fill="none"
|
27
|
+
xmlns="http://www.w3.org/2000/svg"
|
28
|
+
>
|
29
|
+
<line
|
30
|
+
x1="0"
|
31
|
+
y1="12"
|
32
|
+
x2="${length}"
|
33
|
+
y2="12"
|
34
|
+
stroke-width="1"
|
35
|
+
stroke="var(--element-neutral-color)"
|
36
|
+
stroke-dasharray="4,2"
|
37
|
+
stroke-dashoffset="2"
|
38
|
+
/>
|
39
|
+
</svg> `;
|
40
|
+
}
|
41
|
+
|
42
|
+
const color = lineColor(this.medium);
|
43
|
+
const length = this.length * 24 + 1;
|
44
|
+
const width = lineWidth(this.lineType);
|
45
|
+
|
46
|
+
return html`
|
47
|
+
<div class="wrapper" style="height: 24px; width: ${this.length * 24}px;">
|
48
|
+
<svg
|
49
|
+
class="line"
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
51
|
+
viewBox="-.5 0 ${length} 24"
|
52
|
+
height="24"
|
53
|
+
width=${length}
|
54
|
+
>
|
55
|
+
<line
|
56
|
+
x1="-0.5"
|
57
|
+
y1="12"
|
58
|
+
x2="${length - 0.5}"
|
59
|
+
y2="12"
|
60
|
+
stroke-width=${width}
|
61
|
+
stroke="var(${color.inner})"
|
62
|
+
/>
|
63
|
+
<line
|
64
|
+
x1="-0.5"
|
65
|
+
y1="${12 - 0.5 - width / 2}"
|
66
|
+
x2="${length - 0.5}"
|
67
|
+
y2="${12 - 0.5 - width / 2}"
|
68
|
+
stroke-width="1"
|
69
|
+
stroke="var(${color.outer})"
|
70
|
+
/>
|
71
|
+
<line
|
72
|
+
x1="-0.5"
|
73
|
+
y1="${12 + 0.5 + width / 2}"
|
74
|
+
x2="${length - 0.5}"
|
75
|
+
y2="${12 + 0.5 + width / 2}"
|
76
|
+
stroke-width="1"
|
77
|
+
stroke="var(${color.outer})"
|
78
|
+
/>
|
79
|
+
</svg>
|
80
|
+
</div>
|
81
|
+
`;
|
82
|
+
}
|
83
|
+
|
84
|
+
static override styles = css`
|
85
|
+
:host {
|
86
|
+
display: block;
|
87
|
+
line-height: 0;
|
88
|
+
}
|
89
|
+
.line {
|
90
|
+
position: relative;
|
91
|
+
left: -0.5px;
|
92
|
+
}
|
93
|
+
`;
|
94
|
+
}
|
95
|
+
|
96
|
+
declare global {
|
97
|
+
interface HTMLElementTagNameMap {
|
98
|
+
'obc-horizontal-line': ObcHorizontalLine;
|
99
|
+
}
|
100
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
export enum LineMedium {
|
2
|
+
normal = 'normal',
|
3
|
+
empty = 'empty',
|
4
|
+
water = 'water',
|
5
|
+
air = 'air',
|
6
|
+
}
|
7
|
+
export type LineMediumType = keyof typeof LineMedium;
|
8
|
+
|
9
|
+
export enum LineType {
|
10
|
+
fluid = 'fluid',
|
11
|
+
electric = 'electric',
|
12
|
+
air = 'air',
|
13
|
+
connector = 'connector',
|
14
|
+
}
|
15
|
+
export type LineTypeType = keyof typeof LineType;
|
16
|
+
|
17
|
+
export function lineColor(medium: LineMediumType): {
|
18
|
+
inner: string;
|
19
|
+
outer: string;
|
20
|
+
} {
|
21
|
+
let innerColor = '--automation-pipe-primary-color';
|
22
|
+
if (medium === LineMedium.empty) {
|
23
|
+
innerColor = '--automation-pipe-primary-inverted-color';
|
24
|
+
} else if (medium === LineMedium.water || medium === LineMedium.air) {
|
25
|
+
innerColor = '--automation-fresh-water';
|
26
|
+
}
|
27
|
+
return {inner: innerColor, outer: '--automation-pipe-tertiary-color'};
|
28
|
+
}
|
29
|
+
|
30
|
+
export function lineWidth(lineType: LineTypeType): number {
|
31
|
+
if (lineType === LineType.electric) {
|
32
|
+
return 2;
|
33
|
+
} else if (lineType === LineType.connector) {
|
34
|
+
return 1;
|
35
|
+
} else if (lineType === LineType.fluid) {
|
36
|
+
return 4;
|
37
|
+
} else if (lineType === LineType.air) {
|
38
|
+
return 10;
|
39
|
+
}
|
40
|
+
throw new Error('Unknown line type');
|
41
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcVerticalLine} from './vertical-line';
|
3
|
+
import './vertical-line/vertical-line';
|
4
|
+
import './horizontal-line/horizontal-line';
|
5
|
+
import './corner-line/corner-line';
|
6
|
+
import {LineMedium, LineType} from './index';
|
7
|
+
import {html} from 'lit';
|
8
|
+
|
9
|
+
const meta: Meta = {
|
10
|
+
title: 'Line/Example',
|
11
|
+
tags: ['autodocs'],
|
12
|
+
argTypes: {
|
13
|
+
medium: {
|
14
|
+
options: ['normal', 'empty', 'water', 'air'],
|
15
|
+
control: {type: 'radio'},
|
16
|
+
},
|
17
|
+
lineType: {
|
18
|
+
options: ['fluid', 'electric', 'air', 'connector'],
|
19
|
+
control: {type: 'radio'},
|
20
|
+
},
|
21
|
+
},
|
22
|
+
render: (args) => {
|
23
|
+
return html`
|
24
|
+
<style>
|
25
|
+
.canvas {
|
26
|
+
position: relative;
|
27
|
+
width: 400px;
|
28
|
+
height: 400px;
|
29
|
+
}
|
30
|
+
|
31
|
+
#line1 {
|
32
|
+
position: absolute;
|
33
|
+
top: calc(24px * 1);
|
34
|
+
left: calc(24px * 0);
|
35
|
+
}
|
36
|
+
|
37
|
+
#corner-1-2 {
|
38
|
+
position: absolute;
|
39
|
+
top: calc(24px * 0);
|
40
|
+
left: calc(24px * 0);
|
41
|
+
}
|
42
|
+
|
43
|
+
#line2 {
|
44
|
+
position: absolute;
|
45
|
+
top: calc(24px * 0);
|
46
|
+
left: calc(24px * 1);
|
47
|
+
}
|
48
|
+
#corner-2-3 {
|
49
|
+
position: absolute;
|
50
|
+
top: calc(24px * 0);
|
51
|
+
left: calc(24px * 6);
|
52
|
+
}
|
53
|
+
|
54
|
+
#line3 {
|
55
|
+
position: absolute;
|
56
|
+
top: calc(24px * 1);
|
57
|
+
left: calc(24px * 6);
|
58
|
+
}
|
59
|
+
</style>
|
60
|
+
<div class="canvas">
|
61
|
+
<obc-vertical-line
|
62
|
+
medium=${args.medium}
|
63
|
+
line-type=${args.lineType}
|
64
|
+
length="5"
|
65
|
+
id="line1"
|
66
|
+
></obc-vertical-line>
|
67
|
+
<obc-corner-line
|
68
|
+
medium=${args.medium}
|
69
|
+
line-type=${args.lineType}
|
70
|
+
direction="bottom-right"
|
71
|
+
id="corner-1-2"
|
72
|
+
></obc-corner-line>
|
73
|
+
<obc-horizontal-line
|
74
|
+
medium=${args.medium}
|
75
|
+
line-type=${args.lineType}
|
76
|
+
length="5"
|
77
|
+
id="line2"
|
78
|
+
></obc-horizontal-line>
|
79
|
+
<obc-corner-line
|
80
|
+
medium=${args.medium}
|
81
|
+
line-type=${args.lineType}
|
82
|
+
direction="bottom-left"
|
83
|
+
id="corner-2-3"
|
84
|
+
></obc-corner-line>
|
85
|
+
<obc-vertical-line
|
86
|
+
medium=${args.medium}
|
87
|
+
line-type=${args.lineType}
|
88
|
+
length="2"
|
89
|
+
id="line3"
|
90
|
+
></obc-vertical-line>
|
91
|
+
</div>
|
92
|
+
`;
|
93
|
+
},
|
94
|
+
} satisfies Meta<ObcVerticalLine>;
|
95
|
+
|
96
|
+
export default meta;
|
97
|
+
type Story = StoryObj<ObcVerticalLine>;
|
98
|
+
|
99
|
+
export const Fluid: Story = {
|
100
|
+
args: {
|
101
|
+
medium: LineMedium.water,
|
102
|
+
lineType: LineType.fluid,
|
103
|
+
},
|
104
|
+
argTypes: {
|
105
|
+
medium: {
|
106
|
+
options: ['normal', 'empty', 'water'],
|
107
|
+
control: {type: 'radio'},
|
108
|
+
},
|
109
|
+
},
|
110
|
+
};
|
111
|
+
|
112
|
+
export const Electric: Story = {
|
113
|
+
args: {
|
114
|
+
medium: LineMedium.normal,
|
115
|
+
lineType: LineType.electric,
|
116
|
+
},
|
117
|
+
medium: {
|
118
|
+
options: ['normal', 'empty'],
|
119
|
+
control: {type: 'radio'},
|
120
|
+
},
|
121
|
+
};
|
122
|
+
|
123
|
+
export const Air: Story = {
|
124
|
+
args: {
|
125
|
+
medium: LineMedium.air,
|
126
|
+
lineType: LineType.air,
|
127
|
+
},
|
128
|
+
argTypes: {
|
129
|
+
medium: {
|
130
|
+
options: ['normal', 'empty', 'air'],
|
131
|
+
control: {type: 'radio'},
|
132
|
+
},
|
133
|
+
},
|
134
|
+
};
|
135
|
+
|
136
|
+
export const Connector: Story = {
|
137
|
+
args: {
|
138
|
+
medium: LineMedium.normal,
|
139
|
+
lineType: LineType.connector,
|
140
|
+
},
|
141
|
+
argTypes: {},
|
142
|
+
};
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcVerticalLine} from './vertical-line';
|
3
|
+
import './vertical-line';
|
4
|
+
import '../horizontal-line/horizontal-line';
|
5
|
+
import {html} from 'lit';
|
6
|
+
|
7
|
+
const meta: Meta<typeof ObcVerticalLine> = {
|
8
|
+
title: 'Line/Vertical line',
|
9
|
+
tags: ['autodocs'],
|
10
|
+
component: 'obc-vertical-line',
|
11
|
+
argTypes: {
|
12
|
+
medium: {
|
13
|
+
options: ['normal', 'empty', 'water'],
|
14
|
+
control: {type: 'radio'},
|
15
|
+
},
|
16
|
+
},
|
17
|
+
} satisfies Meta<ObcVerticalLine>;
|
18
|
+
|
19
|
+
export default meta;
|
20
|
+
type Story = StoryObj<ObcVerticalLine>;
|
21
|
+
|
22
|
+
export const Primary: Story = {
|
23
|
+
args: {
|
24
|
+
length: 3,
|
25
|
+
},
|
26
|
+
argTypes: {
|
27
|
+
medium: {
|
28
|
+
options: ['normal', 'empty', 'water'],
|
29
|
+
control: {type: 'radio'},
|
30
|
+
},
|
31
|
+
lineType: {
|
32
|
+
options: ['fluid', 'electric', 'air', 'connector'],
|
33
|
+
control: {type: 'radio'},
|
34
|
+
},
|
35
|
+
},
|
36
|
+
};
|
37
|
+
|
38
|
+
export const Complex: Story = {
|
39
|
+
render: () => {
|
40
|
+
return html`
|
41
|
+
<style>
|
42
|
+
.canvas {
|
43
|
+
position: relative;
|
44
|
+
width: 400px;
|
45
|
+
height: 400px;
|
46
|
+
}
|
47
|
+
|
48
|
+
#line1 {
|
49
|
+
position: absolute;
|
50
|
+
top: 24px;
|
51
|
+
}
|
52
|
+
|
53
|
+
#line2 {
|
54
|
+
position: absolute;
|
55
|
+
top: calc(24px * 3);
|
56
|
+
left: calc(24px * 5);
|
57
|
+
}
|
58
|
+
#line3 {
|
59
|
+
position: absolute;
|
60
|
+
top: calc(24px * 3);
|
61
|
+
left: calc(24px * 5);
|
62
|
+
}
|
63
|
+
</style>
|
64
|
+
<div class="canvas">
|
65
|
+
<obc-vertical-line length="5" id="line1"></obc-vertical-line>
|
66
|
+
<obc-vertical-line length="2" id="line2"></obc-vertical-line>
|
67
|
+
<obc-horizontal-line length="5" id="line3"></obc-horizontal-line>
|
68
|
+
</div>
|
69
|
+
`;
|
70
|
+
},
|
71
|
+
};
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import {LitElement, html, css} from 'lit';
|
2
|
+
import {customElement, property} from 'lit/decorators.js';
|
3
|
+
import {
|
4
|
+
LineMedium,
|
5
|
+
LineMediumType,
|
6
|
+
lineColor,
|
7
|
+
LineType,
|
8
|
+
LineTypeType,
|
9
|
+
lineWidth,
|
10
|
+
} from '../index';
|
11
|
+
|
12
|
+
/* Vertical line component
|
13
|
+
*
|
14
|
+
* The vertical line is 24px * length + 1px. +1 px to make sure that connecting lines are overlapping, to hide the gap between them.
|
15
|
+
*/
|
16
|
+
@customElement('obc-vertical-line')
|
17
|
+
export class ObcVerticalLine extends LitElement {
|
18
|
+
@property({type: String}) medium: LineMediumType = LineMedium.normal;
|
19
|
+
@property({type: String, attribute: 'line-type'}) lineType: LineTypeType =
|
20
|
+
LineType.fluid;
|
21
|
+
@property({type: Number}) length: number = 1;
|
22
|
+
|
23
|
+
override render() {
|
24
|
+
if (this.lineType === LineType.connector) {
|
25
|
+
const length = this.length * 24;
|
26
|
+
return html`<svg
|
27
|
+
width="24"
|
28
|
+
height="${length}"
|
29
|
+
viewBox="0 0 24 ${length}"
|
30
|
+
fill="none"
|
31
|
+
xmlns="http://www.w3.org/2000/svg"
|
32
|
+
>
|
33
|
+
<line
|
34
|
+
y1="0"
|
35
|
+
x1="12"
|
36
|
+
y2="${length}"
|
37
|
+
x2="12"
|
38
|
+
stroke-width="1"
|
39
|
+
stroke="var(--element-neutral-color)"
|
40
|
+
stroke-dasharray="4,2"
|
41
|
+
stroke-dashoffset="2"
|
42
|
+
/>
|
43
|
+
</svg> `;
|
44
|
+
}
|
45
|
+
|
46
|
+
const length = this.length * 24 + 1;
|
47
|
+
const color = lineColor(this.medium);
|
48
|
+
const width = lineWidth(this.lineType);
|
49
|
+
return html`
|
50
|
+
<div class="wrapper" style="width: 24px; height: ${this.length * 24}px;">
|
51
|
+
<svg
|
52
|
+
class="line"
|
53
|
+
xmlns="http://www.w3.org/2000/svg"
|
54
|
+
viewBox="0 -.5 24 ${length}"
|
55
|
+
width="24"
|
56
|
+
height=${length}
|
57
|
+
>
|
58
|
+
<line
|
59
|
+
y1="-.5"
|
60
|
+
x1="12"
|
61
|
+
y2="${length - 0.5}"
|
62
|
+
x2="12"
|
63
|
+
stroke-width=${width}
|
64
|
+
stroke="var(${color.inner})"
|
65
|
+
/>
|
66
|
+
<line
|
67
|
+
y1="-.5"
|
68
|
+
x1=${12 - 0.5 - width / 2}
|
69
|
+
y2="${length - 0.5}"
|
70
|
+
x2=${12 - 0.5 - width / 2}
|
71
|
+
stroke-width="1"
|
72
|
+
stroke="var(${color.outer})"
|
73
|
+
/>
|
74
|
+
<line
|
75
|
+
y1="-.5"
|
76
|
+
x1=${12 + 0.5 + width / 2}
|
77
|
+
y2="${length - 0.5}"
|
78
|
+
x2=${12 + 0.5 + width / 2}
|
79
|
+
stroke-width="1"
|
80
|
+
stroke="var(${color.outer})"
|
81
|
+
/>
|
82
|
+
</svg>
|
83
|
+
</div>
|
84
|
+
`;
|
85
|
+
}
|
86
|
+
|
87
|
+
static override styles = css`
|
88
|
+
:host {
|
89
|
+
display: block;
|
90
|
+
line-height: 0;
|
91
|
+
}
|
92
|
+
|
93
|
+
.line {
|
94
|
+
position: relative;
|
95
|
+
top: -0.5px;
|
96
|
+
}
|
97
|
+
`;
|
98
|
+
}
|
99
|
+
|
100
|
+
declare global {
|
101
|
+
interface HTMLElementTagNameMap {
|
102
|
+
'obc-vertical-line': ObcVerticalLine;
|
103
|
+
}
|
104
|
+
}
|
@@ -62,6 +62,8 @@ export class ObcBrillianceMenu extends LitElement {
|
|
62
62
|
min="0"
|
63
63
|
max="100"
|
64
64
|
hug-container
|
65
|
+
has-left-icon
|
66
|
+
has-right-icon
|
65
67
|
>
|
66
68
|
<obi-04-brilliance-low slot="icon-left"></obi-04-brilliance-low>
|
67
69
|
<obi-04-brilliance-high slot="icon-right"></obi-04-brilliance-high>
|
@@ -22,6 +22,7 @@
|
|
22
22
|
position: relative;
|
23
23
|
}
|
24
24
|
|
25
|
+
|
25
26
|
.slider {
|
26
27
|
position: absolute;
|
27
28
|
-webkit-appearance: none;
|
@@ -70,6 +71,25 @@
|
|
70
71
|
background: var(--selected-enabled-background-color);
|
71
72
|
}
|
72
73
|
|
74
|
+
.no-input .interactive-track {
|
75
|
+
width: calc(var(--ratio) * 100% + (1 - 2 * var(--ratio)) * 4px);
|
76
|
+
}
|
77
|
+
|
78
|
+
|
79
|
+
/* used in non-interactive mode */
|
80
|
+
.passive-thumb {
|
81
|
+
position: absolute;
|
82
|
+
width: 16px;
|
83
|
+
height: 16px;
|
84
|
+
top: 16px;
|
85
|
+
left: calc(var(--ratio) * 100% - 8px + (1 - 2 * var(--ratio)) * 4px);
|
86
|
+
border-radius: 100%;
|
87
|
+
border-width: 4px;
|
88
|
+
border-style: solid;
|
89
|
+
border-color: var(--container-background-color);
|
90
|
+
background: var(--selected-enabled-background-color);
|
91
|
+
}
|
92
|
+
|
73
93
|
.wrapper:hover .interactive-track {
|
74
94
|
background: var(--selected-hover-background-color);
|
75
95
|
}
|
@@ -17,7 +17,9 @@ const meta: Meta<typeof ObcSlider> = {
|
|
17
17
|
step: {
|
18
18
|
control: {type: 'number', min: 1, max: 100, step: 1},
|
19
19
|
},
|
20
|
-
|
20
|
+
hugContainer: {
|
21
|
+
control: {type: 'boolean'},
|
22
|
+
},
|
21
23
|
iconLeft: {
|
22
24
|
options: iconIds,
|
23
25
|
control: {type: 'select'},
|
@@ -34,6 +36,9 @@ const meta: Meta<typeof ObcSlider> = {
|
|
34
36
|
min="0"
|
35
37
|
max="100"
|
36
38
|
?hug-container=${args.hugContainer}
|
39
|
+
?has-left-icon=${args.iconLeft ? true : false}
|
40
|
+
?has-right-icon=${args.iconRight ? true : false}
|
41
|
+
variant=${args.variant}
|
37
42
|
>
|
38
43
|
${args.iconLeft
|
39
44
|
? iconIdToIconHtml(args.iconLeft as unknown as string, {
|
@@ -62,6 +67,13 @@ export const Primary: Story = {
|
|
62
67
|
},
|
63
68
|
};
|
64
69
|
|
70
|
+
export const NoIcons: Story = {
|
71
|
+
args: {
|
72
|
+
value: 20,
|
73
|
+
hugContainer: false,
|
74
|
+
},
|
75
|
+
};
|
76
|
+
|
65
77
|
export const HugContainer: Story = {
|
66
78
|
args: {
|
67
79
|
value: 20,
|
@@ -70,3 +82,10 @@ export const HugContainer: Story = {
|
|
70
82
|
hugContainer: true,
|
71
83
|
},
|
72
84
|
};
|
85
|
+
|
86
|
+
export const NoValue: Story = {
|
87
|
+
args: {
|
88
|
+
value: 20,
|
89
|
+
variant: 'no-input',
|
90
|
+
},
|
91
|
+
};
|
@@ -4,6 +4,14 @@ import {styleMap} from 'lit/directives/style-map.js';
|
|
4
4
|
import {ifDefined} from 'lit/directives/if-defined.js';
|
5
5
|
import componentStyle from './slider.css?inline';
|
6
6
|
import '../icon-button/icon-button';
|
7
|
+
import {classMap} from 'lit/directives/class-map.js';
|
8
|
+
|
9
|
+
export enum ObcSliderVariant {
|
10
|
+
NoValue = 'no-value',
|
11
|
+
NoInput = 'no-input',
|
12
|
+
}
|
13
|
+
|
14
|
+
export type ObcSliderVariantType = 'no-value' | 'no-input';
|
7
15
|
|
8
16
|
/**
|
9
17
|
* @element obc-slider
|
@@ -27,6 +35,9 @@ export class ObcSlider extends LitElement {
|
|
27
35
|
@property({type: Number}) max = 100;
|
28
36
|
@property({type: Number}) step: number | undefined;
|
29
37
|
@property({type: Number, attribute: 'step-click'}) stepClick = 10;
|
38
|
+
@property({type: String}) variant: ObcSliderVariantType = 'no-value';
|
39
|
+
@property({type: Boolean, attribute: 'has-left-icon'}) hasLeftIcon = false;
|
40
|
+
@property({type: Boolean, attribute: 'has-right-icon'}) hasRightIcon = false;
|
30
41
|
|
31
42
|
onInput(value: number) {
|
32
43
|
this.value = value;
|
@@ -44,31 +55,44 @@ export class ObcSlider extends LitElement {
|
|
44
55
|
override render() {
|
45
56
|
const ratio = (this.value - this.min) / (this.max - this.min);
|
46
57
|
return html`
|
47
|
-
|
48
|
-
<
|
49
|
-
|
50
|
-
|
58
|
+
${this.hasLeftIcon
|
59
|
+
? html` <obc-icon-button @click=${this.onReduceClick} variant="flat">
|
60
|
+
<slot name="icon-left"></slot>
|
61
|
+
</obc-icon-button>`
|
62
|
+
: null}
|
63
|
+
<div class=${classMap({wrapper: true, [this.variant]: true})}>
|
51
64
|
<div class="track"></div>
|
52
65
|
<div
|
53
66
|
class="interactive-track"
|
54
67
|
style=${styleMap({'--ratio': ratio})}
|
55
68
|
></div>
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
${this.variant === ObcSliderVariant.NoInput
|
70
|
+
? html`<div
|
71
|
+
class="passive-thumb"
|
72
|
+
style=${styleMap({'--ratio': ratio})}
|
73
|
+
></div>`
|
74
|
+
: html`
|
75
|
+
<input
|
76
|
+
type="range"
|
77
|
+
min=${this.min}
|
78
|
+
max=${this.max}
|
79
|
+
step=${ifDefined(this.step)}
|
80
|
+
.value=${this.value.toString()}
|
81
|
+
class="slider"
|
82
|
+
@input=${(event: Event) => {
|
83
|
+
this.value = Number((event.target as HTMLInputElement).value);
|
84
|
+
this.dispatchEvent(
|
85
|
+
new CustomEvent('value', {detail: this.value})
|
86
|
+
);
|
87
|
+
}}
|
88
|
+
/>
|
89
|
+
`}
|
68
90
|
</div>
|
69
|
-
|
70
|
-
|
71
|
-
|
91
|
+
${this.hasRightIcon
|
92
|
+
? html`<obc-icon-button @click=${this.onIncreaseClick} variant="flat">
|
93
|
+
<slot name="icon-right"></slot>
|
94
|
+
</obc-icon-button>`
|
95
|
+
: null}
|
72
96
|
`;
|
73
97
|
}
|
74
98
|
|
@@ -202,14 +202,16 @@ export class ObcTopBar extends LitElement {
|
|
202
202
|
<obi-01-apps></obi-01-apps>
|
203
203
|
</obc-icon-button>`
|
204
204
|
: null}
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
205
|
+
${!this.inactive
|
206
|
+
? html`<obc-icon-button
|
207
|
+
class="left-more-button"
|
208
|
+
variant="flat"
|
209
|
+
@click=${this.leftMoreButtonClicked}
|
210
|
+
?activated=${this.leftMoreButtonActivated}
|
211
|
+
>
|
212
|
+
<obi-01-more-vertical></obi-01-more-vertical>
|
213
|
+
</obc-icon-button>`
|
214
|
+
: null}
|
213
215
|
</div>
|
214
216
|
</nav>
|
215
217
|
`;
|