@oicl/openbridge-webcomponents 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.release-it.json +12 -0
- package/.storybook/main.ts +17 -0
- package/.storybook/preview.ts +0 -1
- package/CHANGELOG.md +118 -41
- package/__snapshots__/application-topbar--inactive.png +0 -0
- package/__snapshots__/button-button--raised-disabled.png +0 -0
- package/__snapshots__/button-rich-button--with-graphic-info.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 +679 -297
- 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/button/button.css.js +2 -2
- package/dist/components/navigation-item/navigation-item.css.js +2 -1
- package/dist/components/navigation-item/navigation-item.css.js.map +1 -1
- package/dist/components/notification-button/notification-button.css.js +1 -1
- package/dist/components/rich-button/rich-button.css.js +20 -10
- package/dist/components/rich-button/rich-button.css.js.map +1 -1
- package/dist/components/rich-button/rich-button.d.ts +1 -0
- package/dist/components/rich-button/rich-button.d.ts.map +1 -1
- package/dist/components/rich-button/rich-button.js +5 -0
- package/dist/components/rich-button/rich-button.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/fix-generated.cjs +1 -0
- package/package.json +20 -26
- 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/rich-button/rich-button.css +15 -2
- package/src/components/rich-button/rich-button.stories.ts +36 -0
- package/src/components/rich-button/rich-button.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/.yarnrc.yml +0 -1
- 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
- package/test.svg +0 -3
@@ -0,0 +1,31 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcCornerLine} from './corner-line';
|
3
|
+
import './corner-line';
|
4
|
+
|
5
|
+
const meta: Meta<typeof ObcCornerLine> = {
|
6
|
+
title: 'Line/Corner line',
|
7
|
+
tags: ['autodocs'],
|
8
|
+
component: 'obc-corner-line',
|
9
|
+
args: {},
|
10
|
+
argTypes: {
|
11
|
+
direction: {
|
12
|
+
options: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
|
13
|
+
control: {type: 'radio'},
|
14
|
+
},
|
15
|
+
medium: {
|
16
|
+
options: ['normal', 'empty', 'water'],
|
17
|
+
control: {type: 'radio'},
|
18
|
+
},
|
19
|
+
lineType: {
|
20
|
+
options: ['fluid', 'electric', 'air', 'connector'],
|
21
|
+
control: {type: 'radio'},
|
22
|
+
},
|
23
|
+
},
|
24
|
+
} satisfies Meta<ObcCornerLine>;
|
25
|
+
|
26
|
+
export default meta;
|
27
|
+
type Story = StoryObj<ObcCornerLine>;
|
28
|
+
|
29
|
+
export const Primary: Story = {
|
30
|
+
args: {},
|
31
|
+
};
|
@@ -0,0 +1,167 @@
|
|
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
|
+
export enum CornerLineDirection {
|
13
|
+
topRight = 'top-right',
|
14
|
+
topLeft = 'top-left',
|
15
|
+
bottomRight = 'bottom-right',
|
16
|
+
bottomLeft = 'bottom-left',
|
17
|
+
}
|
18
|
+
|
19
|
+
export type CornerLineDirectionType =
|
20
|
+
| 'top-right'
|
21
|
+
| 'top-left'
|
22
|
+
| 'bottom-right'
|
23
|
+
| 'bottom-left';
|
24
|
+
|
25
|
+
@customElement('obc-corner-line')
|
26
|
+
export class ObcCornerLine extends LitElement {
|
27
|
+
@property({type: String}) medium: LineMediumType = LineMedium.normal;
|
28
|
+
@property({type: String}) direction: CornerLineDirectionType =
|
29
|
+
CornerLineDirection.topRight;
|
30
|
+
@property({type: String, attribute: 'line-type'}) lineType: LineTypeType =
|
31
|
+
LineType.fluid;
|
32
|
+
|
33
|
+
override render() {
|
34
|
+
let rotation = 270;
|
35
|
+
if (this.direction === CornerLineDirection.topLeft) {
|
36
|
+
rotation = 180;
|
37
|
+
} else if (this.direction === CornerLineDirection.bottomLeft) {
|
38
|
+
rotation = 90;
|
39
|
+
} else if (this.direction === CornerLineDirection.bottomRight) {
|
40
|
+
rotation = 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (this.lineType === LineType.connector) {
|
44
|
+
return html`
|
45
|
+
<svg
|
46
|
+
width="24"
|
47
|
+
height="24"
|
48
|
+
viewBox="0 0 24 24"
|
49
|
+
fill="none"
|
50
|
+
xmlns="http://www.w3.org/2000/svg"
|
51
|
+
transform="rotate(${rotation})"
|
52
|
+
>
|
53
|
+
<path
|
54
|
+
d="M16.5 11.5L15 11.5C14.9951 11.5 14.9902 11.5 14.9853 11.5C13.0826 11.5079 11.5382 13.0339 11.5007 14.9294C11.5002 14.9529 11.5 14.9764 11.5 15V16.5L12.5 16.5L12.5 15C12.5 13.6355 13.5932 12.5263 14.9516 12.5005C14.9677 12.5002 14.9838 12.5 15 12.5L16.5 12.5V11.5Z"
|
55
|
+
fill="var(--element-neutral-color)"
|
56
|
+
/>
|
57
|
+
<path
|
58
|
+
d="M24 11.5H22.5V12.5L24 12.5V11.5Z"
|
59
|
+
fill="var(--element-neutral-color)"
|
60
|
+
/>
|
61
|
+
<path
|
62
|
+
d="M21 11.5H18V12.5L21 12.5V11.5Z"
|
63
|
+
fill="var(--element-neutral-color)"
|
64
|
+
/>
|
65
|
+
<path
|
66
|
+
d="M11.5 18V21H12.5L12.5 18H11.5Z"
|
67
|
+
fill="var(--element-neutral-color)"
|
68
|
+
/>
|
69
|
+
<path
|
70
|
+
d="M11.5 22.5V24H12.5V22.5H11.5Z"
|
71
|
+
fill="var(--element-neutral-color)"
|
72
|
+
/>
|
73
|
+
</svg>
|
74
|
+
`;
|
75
|
+
}
|
76
|
+
|
77
|
+
const color = lineColor(this.medium);
|
78
|
+
const width = lineWidth(this.lineType);
|
79
|
+
|
80
|
+
const r1 = 6 - 0.5 - width / 2;
|
81
|
+
const r2 = 6 + 0.5 + width / 2;
|
82
|
+
|
83
|
+
if (this.lineType === LineType.air) {
|
84
|
+
const r1 = 2.5;
|
85
|
+
const r2 = 11.5;
|
86
|
+
return html`
|
87
|
+
<svg
|
88
|
+
class="line"
|
89
|
+
xmlns="http://www.w3.org/2000/svg"
|
90
|
+
viewBox="0 0 24 24"
|
91
|
+
height="24"
|
92
|
+
width="24"
|
93
|
+
transform="rotate(${rotation})"
|
94
|
+
>
|
95
|
+
<path
|
96
|
+
d="M 17 24 v -4 a 3 3 0 0 1 3 -3 h 4 v -10 h -6 a 11 11 0 0 0 -11 11 v 6 z"
|
97
|
+
stroke="none"
|
98
|
+
fill="var(${color.inner})"
|
99
|
+
/>
|
100
|
+
<path
|
101
|
+
d="M ${12 +
|
102
|
+
0.5 +
|
103
|
+
width / 2} 24 v -4 a ${r1} ${r1} 0 0 1 ${r1} -${r1} h 4"
|
104
|
+
stroke-width="1"
|
105
|
+
stroke="var(${color.outer})"
|
106
|
+
fill="none"
|
107
|
+
/>
|
108
|
+
<path
|
109
|
+
d="M ${12 -
|
110
|
+
0.5 -
|
111
|
+
width / 2} 24 v -6 a ${r2} ${r2} 0 0 1 ${r2} -${r2} h 6"
|
112
|
+
stroke-width="1"
|
113
|
+
stroke="var(${color.outer})"
|
114
|
+
fill="none"
|
115
|
+
/>
|
116
|
+
</svg>
|
117
|
+
`;
|
118
|
+
} else {
|
119
|
+
return html`
|
120
|
+
<svg
|
121
|
+
class="line"
|
122
|
+
xmlns="http://www.w3.org/2000/svg"
|
123
|
+
viewBox="0 0 24 24"
|
124
|
+
height="24"
|
125
|
+
width="24"
|
126
|
+
transform="rotate(${rotation})"
|
127
|
+
>
|
128
|
+
<path
|
129
|
+
d="M 12 24 v -6 a 6 6 0 0 1 6 -6 h 6"
|
130
|
+
stroke-width=${width}
|
131
|
+
stroke="var(${color.inner})"
|
132
|
+
fill="none"
|
133
|
+
/>
|
134
|
+
<path
|
135
|
+
d="M ${12 +
|
136
|
+
0.5 +
|
137
|
+
width / 2} 24 v -6 a ${r1} ${r1} 0 0 1 ${r1} -${r1} h 6"
|
138
|
+
stroke-width="1"
|
139
|
+
stroke="var(${color.outer})"
|
140
|
+
fill="none"
|
141
|
+
/>
|
142
|
+
<path
|
143
|
+
d="M ${12 -
|
144
|
+
0.5 -
|
145
|
+
width / 2} 24 v -6 a ${r2} ${r2} 0 0 1 ${r2} -${r2} h 6"
|
146
|
+
stroke-width="1"
|
147
|
+
stroke="var(${color.outer})"
|
148
|
+
fill="none"
|
149
|
+
/>
|
150
|
+
</svg>
|
151
|
+
`;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
static override styles = css`
|
156
|
+
:host {
|
157
|
+
display: block;
|
158
|
+
line-height: 0;
|
159
|
+
}
|
160
|
+
`;
|
161
|
+
}
|
162
|
+
|
163
|
+
declare global {
|
164
|
+
interface HTMLElementTagNameMap {
|
165
|
+
'obc-corner-line': ObcCornerLine;
|
166
|
+
}
|
167
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components';
|
2
|
+
import {ObcHorizontalLine} from './horizontal-line';
|
3
|
+
import './horizontal-line';
|
4
|
+
|
5
|
+
const meta: Meta<typeof ObcHorizontalLine> = {
|
6
|
+
title: 'Line/Horizontal line',
|
7
|
+
tags: ['autodocs'],
|
8
|
+
component: 'obc-horizontal-line',
|
9
|
+
argTypes: {
|
10
|
+
medium: {
|
11
|
+
options: ['normal', 'empty', 'water'],
|
12
|
+
control: {type: 'radio'},
|
13
|
+
},
|
14
|
+
lineType: {
|
15
|
+
options: ['fluid', 'electric', 'air', 'connector'],
|
16
|
+
control: {type: 'radio'},
|
17
|
+
},
|
18
|
+
},
|
19
|
+
} satisfies Meta<ObcHorizontalLine>;
|
20
|
+
|
21
|
+
export default meta;
|
22
|
+
type Story = StoryObj<ObcHorizontalLine>;
|
23
|
+
|
24
|
+
export const Primary: Story = {
|
25
|
+
args: {
|
26
|
+
length: 3,
|
27
|
+
},
|
28
|
+
};
|
@@ -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>
|