@design-system-rte/angular 0.1.1-rc1
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/.editorconfig +15 -0
- package/.storybook/main.ts +25 -0
- package/.storybook/preview.scss +10 -0
- package/.storybook/preview.ts +27 -0
- package/.storybook/tsconfig.doc.json +7 -0
- package/.storybook/tsconfig.json +11 -0
- package/.storybook/typings.d.ts +4 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/tasks.json +42 -0
- package/angular.json +127 -0
- package/package.json +55 -0
- package/src/assets/.gitkeep +0 -0
- package/src/components/button/button.component.html +7 -0
- package/src/components/button/button.component.scss +156 -0
- package/src/components/button/button.component.spec.ts +23 -0
- package/src/components/button/button.component.stories.ts +103 -0
- package/src/components/button/button.component.ts +25 -0
- package/src/components/grid/col/col.directive.ts +37 -0
- package/src/components/grid/grid.directive.stories.ts +149 -0
- package/src/components/grid/grid.directive.ts +24 -0
- package/src/components/link/link.component.html +5 -0
- package/src/components/link/link.component.scss +108 -0
- package/src/components/link/link.component.stories.ts +61 -0
- package/src/components/link/link.component.ts +19 -0
- package/src/components/radio-button/radio-button.component.html +24 -0
- package/src/components/radio-button/radio-button.component.scss +140 -0
- package/src/components/radio-button/radio-button.component.stories.ts +75 -0
- package/src/components/radio-button/radio-button.component.ts +23 -0
- package/src/components/radio-button-group/radio-button-group.component.html +45 -0
- package/src/components/radio-button-group/radio-button-group.component.scss +82 -0
- package/src/components/radio-button-group/radio-button-group.component.stories.ts +124 -0
- package/src/components/radio-button-group/radio-button-group.component.ts +30 -0
- package/tsconfig.app.json +14 -0
- package/tsconfig.json +32 -0
- package/tsconfig.spec.json +14 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<div
|
|
2
|
+
*ngIf="isDisplayed()"
|
|
3
|
+
class="radio-button-group-container">
|
|
4
|
+
<div
|
|
5
|
+
class="radio-button-group-header"
|
|
6
|
+
[ngClass]="{
|
|
7
|
+
'disabled': disabled(),
|
|
8
|
+
'error': error(),
|
|
9
|
+
'read-only': readOnly(),
|
|
10
|
+
}">
|
|
11
|
+
<h3
|
|
12
|
+
*ngIf="showGroupTitle()"
|
|
13
|
+
class="group-title"
|
|
14
|
+
>
|
|
15
|
+
{{ groupTitle() }}
|
|
16
|
+
</h3>
|
|
17
|
+
<p
|
|
18
|
+
*ngIf="showHelpText()"
|
|
19
|
+
class="group-help-text"
|
|
20
|
+
>
|
|
21
|
+
{{ groupHelpText() }}
|
|
22
|
+
|
|
23
|
+
</p>
|
|
24
|
+
<p
|
|
25
|
+
*ngIf="error()"
|
|
26
|
+
class="group-error-message"
|
|
27
|
+
>
|
|
28
|
+
{{ errorMessage() }}
|
|
29
|
+
</p>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="radio-button-group"
|
|
32
|
+
[ngClass]="{'horizontal': direction() === 'horizontal', 'vertical': direction() === 'vertical'}">
|
|
33
|
+
<ng-container
|
|
34
|
+
*ngFor="let item of items()">
|
|
35
|
+
<rte-radio-button
|
|
36
|
+
[label]="item"
|
|
37
|
+
[groupName]="groupName()"
|
|
38
|
+
[showLabel]="showItemsLabel()"
|
|
39
|
+
[disabled]="disabled()"
|
|
40
|
+
[error]="error()"
|
|
41
|
+
[readOnly]="readOnly()"
|
|
42
|
+
/>
|
|
43
|
+
</ng-container>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@use '@design-system-rte/core/tokens/main.scss' as *;
|
|
2
|
+
|
|
3
|
+
.radio-button-group-container {
|
|
4
|
+
display: flex;
|
|
5
|
+
padding: $positive-spacing_0;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
gap: $positive-spacing_100;
|
|
10
|
+
|
|
11
|
+
.radio-button-group-header {
|
|
12
|
+
|
|
13
|
+
.group-title {
|
|
14
|
+
@include typography-heading-s;
|
|
15
|
+
align-self: stretch;
|
|
16
|
+
margin: $positive-spacing_0;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.group-help-text {
|
|
21
|
+
@include typography-text-m;
|
|
22
|
+
color: var(--content-tertiary);
|
|
23
|
+
align-self: stretch;
|
|
24
|
+
margin: $positive-spacing_0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.group-error-message {
|
|
28
|
+
@include typography-text-m-bold;
|
|
29
|
+
color: var(--content-danger);
|
|
30
|
+
align-self: stretch;
|
|
31
|
+
margin: $positive-spacing_0;
|
|
32
|
+
margin-top: $positive-spacing_050;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.error {
|
|
36
|
+
.group-title {
|
|
37
|
+
color: var(--content-danger);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.read-only {
|
|
42
|
+
.group-title {
|
|
43
|
+
color: var(--content-tertiary);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.error{
|
|
47
|
+
.group-title {
|
|
48
|
+
color: var(--content-danger);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.disabled {
|
|
54
|
+
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
|
|
57
|
+
.group-title {
|
|
58
|
+
color: var(--content-disabled);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.group-help-text {
|
|
62
|
+
color: var(--content-disabled);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
.radio-button-group {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: row;
|
|
73
|
+
padding: $positive-spacing_0;
|
|
74
|
+
align-items: flex-start;
|
|
75
|
+
gap: $positive-spacing_300;
|
|
76
|
+
|
|
77
|
+
&.vertical {
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
gap: $positive-spacing_100;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/angular";
|
|
2
|
+
import { userEvent, within, expect } from "@storybook/test";
|
|
3
|
+
import { RadioButtonGroupComponent } from "./radio-button-group.component";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<RadioButtonGroupComponent> = {
|
|
6
|
+
title: "RadioButtonGroup",
|
|
7
|
+
component: RadioButtonGroupComponent,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
argTypes: {
|
|
10
|
+
groupName: {
|
|
11
|
+
control: "text",
|
|
12
|
+
defaultValue: "group1",
|
|
13
|
+
},
|
|
14
|
+
items: {
|
|
15
|
+
control: "object",
|
|
16
|
+
defaultValue: ["Option 1", "Option 2", "Option 3"],
|
|
17
|
+
},
|
|
18
|
+
direction: {
|
|
19
|
+
control: "select",
|
|
20
|
+
options: ["horizontal", "vertical"],
|
|
21
|
+
defaultValue: "horizontal",
|
|
22
|
+
},
|
|
23
|
+
showItemsLabel: {
|
|
24
|
+
control: "boolean",
|
|
25
|
+
defaultValue: true,
|
|
26
|
+
},
|
|
27
|
+
groupTitle: {
|
|
28
|
+
control: "text",
|
|
29
|
+
defaultValue: "Radio Button Group Title",
|
|
30
|
+
},
|
|
31
|
+
showGroupTitle: {
|
|
32
|
+
control: "boolean",
|
|
33
|
+
defaultValue: true,
|
|
34
|
+
},
|
|
35
|
+
groupHelpText: {
|
|
36
|
+
control: "text",
|
|
37
|
+
defaultValue:
|
|
38
|
+
"This is a help text for the radio button group.",
|
|
39
|
+
},
|
|
40
|
+
showHelpText: {
|
|
41
|
+
control: "boolean",
|
|
42
|
+
defaultValue: true,
|
|
43
|
+
},
|
|
44
|
+
errorMessage: {
|
|
45
|
+
control: "text",
|
|
46
|
+
defaultValue:
|
|
47
|
+
'This is an error message. Please select an option.',
|
|
48
|
+
},
|
|
49
|
+
error: {
|
|
50
|
+
control: "boolean",
|
|
51
|
+
defaultValue: false,
|
|
52
|
+
},
|
|
53
|
+
disabled: {
|
|
54
|
+
control: "boolean",
|
|
55
|
+
defaultValue: false,
|
|
56
|
+
},
|
|
57
|
+
readOnly: {
|
|
58
|
+
control: "boolean",
|
|
59
|
+
defaultValue: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export default meta;
|
|
64
|
+
type Story = StoryObj<RadioButtonGroupComponent>;
|
|
65
|
+
|
|
66
|
+
export const Default: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
groupName: "group1",
|
|
69
|
+
items: ["Option 1", "Option 2", "Option 3"],
|
|
70
|
+
direction: "horizontal",
|
|
71
|
+
showItemsLabel: true,
|
|
72
|
+
groupTitle: "Radio Button Group Title",
|
|
73
|
+
showGroupTitle: true,
|
|
74
|
+
groupHelpText:
|
|
75
|
+
"This is a help text for the radio button group.",
|
|
76
|
+
showHelpText: true,
|
|
77
|
+
errorMessage:
|
|
78
|
+
'This is an error message. Please select an option.',
|
|
79
|
+
error: false,
|
|
80
|
+
disabled: false,
|
|
81
|
+
readOnly: false,
|
|
82
|
+
},
|
|
83
|
+
play: async ({ canvasElement }) => {
|
|
84
|
+
const canvas = within(canvasElement);
|
|
85
|
+
const radioButton = canvas.getByLabelText("Option 1");
|
|
86
|
+
await userEvent.click(radioButton);
|
|
87
|
+
expect(radioButton).toBeChecked();
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const Disabled: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
...Default.args,
|
|
94
|
+
disabled: true,
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const Error: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
...Default.args,
|
|
101
|
+
error: true,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const ReadOnly: Story = {
|
|
106
|
+
args: {
|
|
107
|
+
...Default.args,
|
|
108
|
+
readOnly: true,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const Vertical: Story = {
|
|
113
|
+
args: {
|
|
114
|
+
...Default.args,
|
|
115
|
+
direction: "vertical",
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const Horizontal: Story = {
|
|
120
|
+
args: {
|
|
121
|
+
...Default.args,
|
|
122
|
+
direction: "horizontal",
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Component, computed, input } from "@angular/core";
|
|
2
|
+
import { CommonModule } from "@angular/common";
|
|
3
|
+
import { RadioButtonComponent } from "../radio-button/radio-button.component";
|
|
4
|
+
|
|
5
|
+
@Component({
|
|
6
|
+
selector: 'rte-radio-button-group',
|
|
7
|
+
standalone: true,
|
|
8
|
+
imports: [CommonModule, RadioButtonComponent],
|
|
9
|
+
templateUrl: './radio-button-group.component.html',
|
|
10
|
+
styleUrls: ['./radio-button-group.component.scss'],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export class RadioButtonGroupComponent {
|
|
14
|
+
groupName = input('');
|
|
15
|
+
items = input<string[]>([]);
|
|
16
|
+
direction = input('horizontal');
|
|
17
|
+
showItemsLabel = input(true);
|
|
18
|
+
groupTitle = input('');
|
|
19
|
+
showGroupTitle = input(false);
|
|
20
|
+
groupHelpText = input('');
|
|
21
|
+
showHelpText = input(false);
|
|
22
|
+
errorMessage = input('');
|
|
23
|
+
error = input(false);
|
|
24
|
+
disabled = input(false);
|
|
25
|
+
readOnly = input(false);
|
|
26
|
+
|
|
27
|
+
isDisplayed = computed(() => !(this.disabled() && this.error()));
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "./out-tsc/app",
|
|
6
|
+
"types": []
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"src/main.ts"
|
|
10
|
+
],
|
|
11
|
+
"include": [
|
|
12
|
+
"src/**/*.d.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"compileOnSave": false,
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "./dist/out-tsc",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"declaration": false,
|
|
15
|
+
"experimentalDecorators": true,
|
|
16
|
+
"moduleResolution": "node",
|
|
17
|
+
"importHelpers": true,
|
|
18
|
+
"target": "ES2022",
|
|
19
|
+
"module": "ES2022",
|
|
20
|
+
"useDefineForClassFields": false,
|
|
21
|
+
"lib": [
|
|
22
|
+
"ES2022",
|
|
23
|
+
"dom"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"angularCompilerOptions": {
|
|
27
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
28
|
+
"strictInjectionParameters": true,
|
|
29
|
+
"strictInputAccessModifiers": true,
|
|
30
|
+
"strictTemplates": true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
|
2
|
+
{
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "./out-tsc/spec",
|
|
6
|
+
"types": [
|
|
7
|
+
"jasmine"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"src/**/*.spec.ts",
|
|
12
|
+
"src/**/*.d.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|