@design-system-rte/angular 0.1.1-rc3 → 0.1.1-rc4

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.
Files changed (36) hide show
  1. package/ng-package.json +7 -0
  2. package/package.json +3 -16
  3. package/src/lib/components/button/button.component.html +7 -0
  4. package/src/lib/components/button/button.component.scss +156 -0
  5. package/src/lib/components/button/button.component.spec.ts +23 -0
  6. package/src/lib/components/button/button.component.stories.ts +102 -0
  7. package/src/lib/components/button/button.component.ts +25 -0
  8. package/src/lib/components/grid/col/col.directive.ts +37 -0
  9. package/src/lib/components/grid/grid.directive.stories.ts +149 -0
  10. package/src/lib/components/grid/grid.directive.ts +24 -0
  11. package/src/lib/components/link/link.component.html +5 -0
  12. package/src/lib/components/link/link.component.scss +108 -0
  13. package/src/lib/components/link/link.component.stories.ts +61 -0
  14. package/src/lib/components/link/link.component.ts +19 -0
  15. package/src/lib/components/radio-button/radio-button.component.html +24 -0
  16. package/src/lib/components/radio-button/radio-button.component.scss +140 -0
  17. package/src/lib/components/radio-button/radio-button.component.stories.ts +75 -0
  18. package/src/lib/components/radio-button/radio-button.component.ts +23 -0
  19. package/src/lib/components/radio-button-group/radio-button-group.component.html +45 -0
  20. package/src/lib/components/radio-button-group/radio-button-group.component.scss +82 -0
  21. package/src/lib/components/radio-button-group/radio-button-group.component.stories.ts +124 -0
  22. package/src/lib/components/radio-button-group/radio-button-group.component.ts +30 -0
  23. package/src/public-api.ts +5 -0
  24. package/tsconfig.lib.json +14 -0
  25. package/tsconfig.lib.prod.json +10 -0
  26. package/tsconfig.spec.json +14 -0
  27. package/esm2022/design-system-rte-angular.mjs +0 -5
  28. package/esm2022/lib/lib.component.mjs +0 -19
  29. package/esm2022/lib/lib.service.mjs +0 -14
  30. package/esm2022/public-api.mjs +0 -6
  31. package/fesm2022/design-system-rte-angular.mjs +0 -42
  32. package/fesm2022/design-system-rte-angular.mjs.map +0 -1
  33. package/index.d.ts +0 -5
  34. package/lib/lib.component.d.ts +0 -5
  35. package/lib/lib.service.d.ts +0 -6
  36. package/public-api.d.ts +0 -2
@@ -0,0 +1,61 @@
1
+ import { Meta, StoryObj } from '@storybook/angular';
2
+ import { fn, userEvent, within, expect } from '@storybook/test';
3
+
4
+ import { LinkComponent } from './link.component';
5
+
6
+ const meta: Meta<LinkComponent> = {
7
+ title: 'Link',
8
+ component: LinkComponent,
9
+ tags: ['autodocs'],
10
+ argTypes: {
11
+ subtle: {
12
+ control: 'boolean',
13
+ },
14
+ externalLink: {
15
+ control: 'boolean',
16
+ },
17
+ },
18
+ };
19
+ export default meta;
20
+ type Story = StoryObj<LinkComponent>;
21
+
22
+ export const Default: Story = {
23
+ args: {
24
+ label: 'Link',
25
+ href: '#',
26
+ },
27
+ };
28
+
29
+ export const SubtleLink: Story = {
30
+ args: {
31
+ ...Default.args,
32
+ subtle: true,
33
+ },
34
+ }
35
+
36
+ export const SubtleLinkExternal: Story = {
37
+ args: {
38
+ ...SubtleLink.args,
39
+ externalLink: true,
40
+ },
41
+ }
42
+
43
+ export const ExternalLink: Story = {
44
+ args: {
45
+ ...Default.args,
46
+ externalLink: true,
47
+ },
48
+ };
49
+
50
+ export const KeyboardInteraction: Story = {
51
+ args: {
52
+ ...Default.args,
53
+ href: '#',
54
+ },
55
+ play: async ({ canvasElement }) => {
56
+ const canvas = within(canvasElement);
57
+ const link = canvas.getByRole('link');
58
+ await userEvent.tab();
59
+ expect(link).toHaveFocus();
60
+ }
61
+ };
@@ -0,0 +1,19 @@
1
+ import { Component, input } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+
4
+ @Component({
5
+ selector: 'rte-link',
6
+ standalone: true,
7
+ imports: [CommonModule],
8
+ templateUrl: './link.component.html',
9
+ styleUrl: './link.component.scss'
10
+ })
11
+
12
+ export class LinkComponent {
13
+
14
+ label = input('');
15
+ href = input<string>('#');
16
+ subtle = input<boolean>(false);
17
+ externalLink = input<boolean>(false);
18
+
19
+ }
@@ -0,0 +1,24 @@
1
+ <div *ngIf="isDisplayed()" class="rte-radio-button-container">
2
+ <input
3
+ type="radio"
4
+ [id]="label()"
5
+ [value]="label()"
6
+ [size]="labelSize"
7
+ [name]="groupName()"
8
+ class="rte-radio-button"
9
+ [ngClass]="{'error': error(), 'read-only': readOnly()}"
10
+ [disabled]="disabled()"
11
+ />
12
+ <label
13
+ *ngIf="showLabel()"
14
+ [for]="label()"
15
+ class="rte-radio-button-label"
16
+ [ngClass]="{
17
+ 'error': error(),
18
+ 'read-only': readOnly(),
19
+ 'disabled': disabled()
20
+ }"
21
+ >
22
+ {{ label() }}
23
+ </label>
24
+ </div>
@@ -0,0 +1,140 @@
1
+ @use '@design-system-rte/core/tokens/main.scss' as *;
2
+
3
+
4
+ .rte-radio-button-container {
5
+ display: flex;
6
+ padding-right: $positive-spacing_050;
7
+ align-items: center;
8
+ gap: $positive-spacing_150;
9
+ }
10
+
11
+ .rte-radio-button {
12
+ appearance: none;
13
+ display: flex;
14
+ width: 16px;
15
+ height: 16px;
16
+ padding: $positive-spacing_0;
17
+ justify-content: center;
18
+ align-items: center;
19
+ border-radius: $radius-pill;
20
+ border: $width-xs solid var(--content-tertiary);
21
+ background: var(--background-default);
22
+ position: relative;
23
+ cursor: pointer;
24
+ transition: box-shadow 0.3s ease-in-out;
25
+ margin: 0;
26
+
27
+ &::before {
28
+ content: '';
29
+ width: 10px;
30
+ height: 10px;
31
+ border-radius: $radius-pill;
32
+ background: var(--content-brand-default);
33
+ opacity: $opacity-0;
34
+ }
35
+
36
+ &::after {
37
+ content: '';
38
+ width: calc(100% + 8px);
39
+ height: calc(100% + 8px);
40
+ border-radius: $radius-s;
41
+ border: $width-xs solid var(--content-primary);
42
+ position: absolute;
43
+ z-index: -1;
44
+ opacity: $opacity-0;
45
+ }
46
+
47
+ &.error {
48
+ border: $width-xs solid var(--content-danger);
49
+ transition: box-shadow 0.3s ease-in-out;
50
+
51
+ &:checked {
52
+ border: $width-xs solid var(--content-danger);
53
+ }
54
+
55
+ &::before {
56
+ background: var(--content-danger);
57
+ }
58
+
59
+ //TODO: Modify brute variable to use tokens
60
+
61
+ &:hover {
62
+ transition: box-shadow 0.15s ease-in-out;
63
+ box-shadow: 0 0 0 8px rgba(200, 22, 64, 0.2);
64
+
65
+ &:checked {
66
+ box-shadow: 0 0 0 8px rgba(200, 22, 64, 0.2);
67
+ }
68
+ }
69
+ }
70
+
71
+ &.read-only {
72
+ pointer-events: none;
73
+ cursor: default;
74
+
75
+ &::before {
76
+ background: var(--content-tertiary);
77
+ }
78
+
79
+ &:checked {
80
+ border: $width-xs solid var(--content-tertiary);
81
+ }
82
+
83
+ &.error{
84
+ border: $width-xs solid var(--content-danger);
85
+ }
86
+ }
87
+
88
+ &:focus {
89
+ outline: none;
90
+
91
+ &::after {
92
+ opacity: $opacity-100;
93
+ }
94
+ }
95
+
96
+ &:checked {
97
+ border: $width-xs solid var(--content-brand-default);
98
+ }
99
+
100
+ &:checked::before {
101
+ opacity: $opacity-100;
102
+ }
103
+
104
+ //TODO: Modify brute variable to use tokens
105
+
106
+ &:hover {
107
+ transition: box-shadow 0.15s ease-in-out;
108
+ box-shadow: 0 0 0 8px var(--background-hover);
109
+
110
+ &:checked {
111
+ box-shadow: 0 0 0 8px rgba(34, 80, 130, 0.2);
112
+ }
113
+ }
114
+
115
+ &:disabled {
116
+ pointer-events: none;
117
+ background: var(--background-disabled);
118
+ border: $width-xs solid var(--content-disabled);
119
+ cursor: not-allowed;
120
+
121
+ &::before {
122
+ background: var(--content-disabled);
123
+ }
124
+ }
125
+ }
126
+
127
+ .rte-radio-button-label {
128
+ @include typography-radio-button-l;
129
+
130
+ &.read-only {
131
+ pointer-events: none;
132
+ cursor: default;
133
+ color: var(--content-tertiary);
134
+ }
135
+
136
+ &.disabled {
137
+ pointer-events: none;
138
+ color: var(--content-disabled);
139
+ }
140
+ }
@@ -0,0 +1,75 @@
1
+ import { Meta, StoryObj } from '@storybook/angular';
2
+ import { userEvent, within, expect } from '@storybook/test';
3
+ import { RadioButtonComponent } from './radio-button.component';
4
+
5
+ const meta: Meta<RadioButtonComponent> = {
6
+ title: 'RadioButton',
7
+ component: RadioButtonComponent,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ label: {
11
+ control: 'text',
12
+ defaultValue: 'Radio Button',
13
+ },
14
+ groupName: {
15
+ control: 'text',
16
+ defaultValue: 'radio-group',
17
+ },
18
+ showLabel: {
19
+ control: 'boolean',
20
+ defaultValue: true,
21
+ },
22
+ disabled: {
23
+ control: 'boolean',
24
+ defaultValue: false,
25
+ },
26
+ error: {
27
+ control: 'boolean',
28
+ defaultValue: false,
29
+ },
30
+ readOnly: {
31
+ control: 'boolean',
32
+ defaultValue: false,
33
+ },
34
+ },
35
+ };
36
+ export default meta;
37
+ type Story = StoryObj<RadioButtonComponent>;
38
+
39
+ export const Default: Story = {
40
+ args: {
41
+ label: 'Radio Button',
42
+ groupName: 'radio-group',
43
+ showLabel: true,
44
+ disabled: false,
45
+ error: false,
46
+ readOnly: false,
47
+ },
48
+ play: async ({ canvasElement }) => {
49
+ const canvas = within(canvasElement);
50
+ const radioButton = canvas.getByRole('radio');
51
+ await userEvent.click(radioButton);
52
+ expect(radioButton).toBeChecked();
53
+ },
54
+ };
55
+
56
+ export const Disabled: Story = {
57
+ args: {
58
+ ...Default.args,
59
+ disabled: true,
60
+ },
61
+ }
62
+
63
+ export const Error: Story = {
64
+ args: {
65
+ ...Default.args,
66
+ error: true,
67
+ },
68
+ }
69
+
70
+ export const ReadOnly: Story = {
71
+ args: {
72
+ ...Default.args,
73
+ readOnly: true,
74
+ },
75
+ }
@@ -0,0 +1,23 @@
1
+ import { Component,computed,input } from "@angular/core";
2
+ import { labelSize } from "@design-system-rte/core/components/radio-button/radio-button.constants";
3
+ import { CommonModule } from "@angular/common";
4
+
5
+ @Component({
6
+ selector: 'rte-radio-button',
7
+ standalone: true,
8
+ imports: [CommonModule],
9
+ templateUrl: './radio-button.component.html',
10
+ styleUrl: './radio-button.component.scss',
11
+ })
12
+
13
+ export class RadioButtonComponent {
14
+ label = input('');
15
+ groupName = input('');
16
+ showLabel = input(true);
17
+ disabled = input(false);
18
+ error = input(false);
19
+ readOnly = input(false);
20
+ labelSize = labelSize;
21
+
22
+ isDisplayed = computed(() => !(this.disabled() && this.error()));
23
+ }
@@ -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,5 @@
1
+ /*
2
+ * Public API Surface of lib
3
+ */
4
+
5
+ export * from './lib/components/button/button.component';
@@ -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/lib",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "inlineSources": true,
9
+ "types": []
10
+ },
11
+ "exclude": [
12
+ "**/*.spec.ts"
13
+ ]
14
+ }
@@ -0,0 +1,10 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.lib.json",
4
+ "compilerOptions": {
5
+ "declarationMap": false
6
+ },
7
+ "angularCompilerOptions": {
8
+ "compilationMode": "partial"
9
+ }
10
+ }
@@ -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
+ "**/*.spec.ts",
12
+ "**/*.d.ts"
13
+ ]
14
+ }
@@ -1,5 +0,0 @@
1
- /**
2
- * Generated bundle index. Do not edit.
3
- */
4
- export * from './public-api';
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVzaWduLXN5c3RlbS1ydGUtYW5ndWxhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3Byb2plY3RzL2xpYi9zcmMvZGVzaWduLXN5c3RlbS1ydGUtYW5ndWxhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUVILGNBQWMsY0FBYyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBHZW5lcmF0ZWQgYnVuZGxlIGluZGV4LiBEbyBub3QgZWRpdC5cbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL3B1YmxpYy1hcGknO1xuIl19