@ks-digital/designsystem-angular 0.0.1-alpha.25 → 0.0.1-alpha.27

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 (107) hide show
  1. package/fesm2022/ks-digital-designsystem-angular.mjs +1100 -0
  2. package/fesm2022/ks-digital-designsystem-angular.mjs.map +1 -0
  3. package/index.d.ts +333 -0
  4. package/package.json +15 -20
  5. package/.storybook/customTheme.ts +0 -15
  6. package/.storybook/default-args.ts +0 -18
  7. package/.storybook/main.ts +0 -27
  8. package/.storybook/manager.ts +0 -10
  9. package/.storybook/preview-head.html +0 -16
  10. package/.storybook/preview.ts +0 -70
  11. package/.storybook/themes.ts +0 -9
  12. package/.storybook/tsconfig.json +0 -16
  13. package/.storybook/vite.config.mts +0 -5
  14. package/eslint.config.mjs +0 -28
  15. package/ng-package.json +0 -9
  16. package/project.json +0 -81
  17. package/src/components/alert/alert.mdx +0 -46
  18. package/src/components/alert/alert.spec.ts +0 -33
  19. package/src/components/alert/alert.stories.ts +0 -138
  20. package/src/components/alert/alert.ts +0 -46
  21. package/src/components/alert/index.ts +0 -1
  22. package/src/components/button/button.mdx +0 -40
  23. package/src/components/button/button.spec.ts +0 -86
  24. package/src/components/button/button.stories.ts +0 -123
  25. package/src/components/button/button.ts +0 -60
  26. package/src/components/button/index.ts +0 -1
  27. package/src/components/card/card-block.ts +0 -10
  28. package/src/components/card/card.mdx +0 -100
  29. package/src/components/card/card.spec.ts +0 -70
  30. package/src/components/card/card.stories.ts +0 -101
  31. package/src/components/card/card.ts +0 -44
  32. package/src/components/card/index.ts +0 -2
  33. package/src/components/checkbox/README.md +0 -13
  34. package/src/components/checkbox/checkbox.mdx +0 -50
  35. package/src/components/checkbox/checkbox.spec.ts +0 -21
  36. package/src/components/checkbox/checkbox.stories.ts +0 -182
  37. package/src/components/checkbox/index.ts +0 -0
  38. package/src/components/colors.ts +0 -36
  39. package/src/components/common-inputs.ts +0 -30
  40. package/src/components/details/controlled-details.ts +0 -63
  41. package/src/components/details/details-content.ts +0 -7
  42. package/src/components/details/details-summary.ts +0 -7
  43. package/src/components/details/details.mdx +0 -89
  44. package/src/components/details/details.spec.ts +0 -56
  45. package/src/components/details/details.stories.ts +0 -129
  46. package/src/components/details/details.ts +0 -69
  47. package/src/components/details/index.ts +0 -3
  48. package/src/components/field/field-counter.ts +0 -56
  49. package/src/components/field/field-description.ts +0 -10
  50. package/src/components/field/field-error.ts +0 -13
  51. package/src/components/field/field-observer.ts +0 -121
  52. package/src/components/field/field-state.ts +0 -21
  53. package/src/components/field/field.mdx +0 -40
  54. package/src/components/field/field.spec.ts +0 -131
  55. package/src/components/field/field.stories.ts +0 -98
  56. package/src/components/field/field.ts +0 -70
  57. package/src/components/field/index.ts +0 -3
  58. package/src/components/fieldset/fieldset-description.ts +0 -8
  59. package/src/components/fieldset/fieldset-legend.ts +0 -11
  60. package/src/components/fieldset/fieldset.spec.ts +0 -80
  61. package/src/components/fieldset/fieldset.ts +0 -11
  62. package/src/components/fieldset/index.ts +0 -3
  63. package/src/components/input/index.ts +0 -1
  64. package/src/components/input/input.mdx +0 -11
  65. package/src/components/input/input.spec.ts +0 -25
  66. package/src/components/input/input.stories.ts +0 -72
  67. package/src/components/input/input.ts +0 -67
  68. package/src/components/label/index.ts +0 -1
  69. package/src/components/label/label.ts +0 -17
  70. package/src/components/paragraph/index.ts +0 -1
  71. package/src/components/paragraph/paragraph.ts +0 -10
  72. package/src/components/popover/controlled-popover.ts +0 -62
  73. package/src/components/popover/index.ts +0 -1
  74. package/src/components/popover/popover.mdx +0 -81
  75. package/src/components/popover/popover.spec.ts +0 -143
  76. package/src/components/popover/popover.stories.ts +0 -63
  77. package/src/components/popover/popover.ts +0 -186
  78. package/src/components/radio/radio.mdx +0 -117
  79. package/src/components/radio/radio.stories.ts +0 -226
  80. package/src/components/search/index.ts +0 -4
  81. package/src/components/search/search-button.ts +0 -35
  82. package/src/components/search/search-clear.ts +0 -57
  83. package/src/components/search/search-input.ts +0 -18
  84. package/src/components/search/search.mdx +0 -56
  85. package/src/components/search/search.spec.ts +0 -48
  86. package/src/components/search/search.stories.ts +0 -205
  87. package/src/components/search/search.ts +0 -50
  88. package/src/components/spinner/index.ts +0 -1
  89. package/src/components/spinner/spinner.mdx +0 -24
  90. package/src/components/spinner/spinner.spec.ts +0 -13
  91. package/src/components/spinner/spinner.stories.ts +0 -54
  92. package/src/components/spinner/spinner.ts +0 -62
  93. package/src/components/switch/switch.mdx +0 -82
  94. package/src/components/switch/switch.stories.ts +0 -94
  95. package/src/components/textarea/textarea.mdx +0 -14
  96. package/src/components/textarea/textarea.stories.ts +0 -52
  97. package/src/components/validation-message/index.ts +0 -1
  98. package/src/components/validation-message/validation-message.ts +0 -11
  99. package/src/index.ts +0 -14
  100. package/src/test-setup.ts +0 -12
  101. package/src/utils/log-if-devmode.ts +0 -13
  102. package/src/utils/random-id.ts +0 -3
  103. package/tsconfig.json +0 -34
  104. package/tsconfig.lib.json +0 -28
  105. package/tsconfig.lib.prod.json +0 -9
  106. package/tsconfig.spec.json +0 -30
  107. package/vite.config.mts +0 -35
@@ -1,16 +0,0 @@
1
- <link
2
- href="https://static.fiks.ks.no/googlefonts/googleapis/css2?family=Inter:wght@400;500;600;700;800&display=swap"
3
- rel="stylesheet"
4
- />
5
-
6
- <link rel="stylesheet" href="css/base.css" />
7
-
8
- <style>
9
- * {
10
- font-feature-settings: 'cv05' 1;
11
- }
12
- </style>
13
-
14
- <script>
15
- document.documentElement.setAttribute('lang', 'no')
16
- </script>
@@ -1,70 +0,0 @@
1
- import { applicationConfig, type Preview } from '@analogjs/storybook-angular'
2
- import { provideZonelessChangeDetection } from '@angular/core'
3
- import { addons } from 'storybook/preview-api'
4
- import customTheme from './customTheme'
5
- import { themes } from './themes'
6
-
7
- addons.getChannel().on('globalsUpdated', ({ globals }) => {
8
- setTheme(globals.theme)
9
- })
10
-
11
- function setTheme(href: string): void {
12
- let link: HTMLLinkElement | null = document.getElementById(
13
- 'storybook-theme',
14
- ) as HTMLLinkElement | null
15
- href = href ?? themes[0].href
16
- if (!link) {
17
- link = document.createElement('link')
18
- link.rel = 'stylesheet'
19
- link.id = 'storybook-theme'
20
- document.head.appendChild(link)
21
- }
22
- link.href = href
23
- }
24
-
25
- type ThemeGlobalType = {
26
- name: string
27
- description: string
28
- defaultValue: string
29
- toolbar: {
30
- icon: string
31
- items: Array<{ value: string; title: string }>
32
- showName: boolean
33
- }
34
- }
35
-
36
- export const globalTypes: Record<string, ThemeGlobalType> = {
37
- theme: {
38
- name: 'Theme',
39
- description: 'Global theme for components',
40
- defaultValue: themes[0].href,
41
- toolbar: {
42
- icon: 'paintbrush',
43
- items: themes.map((t) => ({ value: t.href, title: t.name })),
44
- showName: true,
45
- },
46
- },
47
- }
48
-
49
- const preview: Preview = {
50
- decorators: [
51
- applicationConfig({
52
- providers: [provideZonelessChangeDetection()],
53
- }),
54
- ],
55
- parameters: {
56
- actions: { argTypesRegex: '^on[A-Z].*' },
57
- controls: {
58
- matchers: {
59
- color: /(background|color)$/i,
60
- date: /Date$/i,
61
- },
62
- },
63
- layout: 'centered',
64
- docs: {
65
- theme: customTheme,
66
- },
67
- },
68
- }
69
-
70
- export default preview
@@ -1,9 +0,0 @@
1
- /**
2
- * Themes that should be available in storybook
3
- */
4
-
5
- export const themes = [
6
- { name: 'Forvaltning', href: 'css/themes/forvaltning.css' },
7
- { name: 'Ledsagerbevis', href: 'css/themes/ledsagerbevis.css' },
8
- { name: 'Min kommune', href: 'css/themes/minkommune.css' },
9
- ]
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "../tsconfig.json",
3
- "compilerOptions": {
4
- "emitDecoratorMetadata": true
5
- },
6
- "exclude": ["../**/*.spec.ts"],
7
- "include": [
8
- "../src/**/*.stories.ts",
9
- "../src/**/*.stories.js",
10
- "../src/**/*.stories.jsx",
11
- "../src/**/*.stories.tsx",
12
- "../src/**/*.stories.mdx",
13
- "*.js",
14
- "*.ts"
15
- ]
16
- }
@@ -1,5 +0,0 @@
1
- import { mergeConfig, type UserConfig } from 'vite'
2
-
3
- export default async function viteFinal(config: UserConfig) {
4
- return mergeConfig(config, {})
5
- }
package/eslint.config.mjs DELETED
@@ -1,28 +0,0 @@
1
- import nx from '@nx/eslint-plugin'
2
- import baseConfig from '../../eslint.config.mjs'
3
-
4
- export default [
5
- ...baseConfig,
6
- ...nx.configs['flat/angular'],
7
- ...nx.configs['flat/angular-template'],
8
- {
9
- files: ['**/*.ts'],
10
- rules: {
11
- '@angular-eslint/component-class-suffix': 'off',
12
- '@angular-eslint/directive-class-suffix': 'off',
13
- '@angular-eslint/directive-selector': [
14
- 'error',
15
- {
16
- type: 'attribute',
17
- prefix: 'ksd',
18
- style: 'camelCase',
19
- },
20
- ],
21
- },
22
- },
23
- {
24
- files: ['**/*.html'],
25
- // Override or add rules here
26
- rules: {},
27
- },
28
- ]
package/ng-package.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/packages/angular",
4
- "assets": ["*.md"],
5
- "lib": {
6
- "entryFile": "src/index.ts"
7
- },
8
- "allowedNonPeerDependencies": ["@floating-ui/dom", "@u-elements/u-details"]
9
- }
package/project.json DELETED
@@ -1,81 +0,0 @@
1
- {
2
- "name": "@ks-digital/designsystem-angular",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/angular/src",
5
- "prefix": "lib",
6
- "projectType": "library",
7
- "tags": [],
8
- "targets": {
9
- "build": {
10
- "executor": "@nx/angular:package",
11
- "dependsOn": ["@ks-digital/designsystem-themes:build"],
12
- "outputs": ["{workspaceRoot}/dist/{projectRoot}"],
13
- "options": {
14
- "tsConfig": "packages/angular/tsconfig.lib.prod.json",
15
- "project": "packages/angular/ng-package.json"
16
- },
17
- "configurations": {
18
- "production": {
19
- "tsConfig": "packages/angular/tsconfig.lib.prod.json"
20
- },
21
- "development": {
22
- "tsConfig": "packages/angular/tsconfig.lib.json"
23
- }
24
- },
25
- "defaultConfiguration": "production"
26
- },
27
- "lint": {
28
- "executor": "@nx/eslint:lint"
29
- },
30
- "storybook": {
31
- "executor": "@analogjs/storybook-angular:start-storybook",
32
- "options": {
33
- "port": 4400,
34
- "configDir": "packages/angular/.storybook",
35
- "compodoc": false
36
- },
37
- "configurations": {
38
- "ci": {
39
- "quiet": true
40
- }
41
- }
42
- },
43
- "build-storybook": {
44
- "executor": "@analogjs/storybook-angular:build-storybook",
45
- "dependsOn": ["@ks-digital/designsystem-themes:build", "^build"],
46
- "outputs": ["{options.outputDir}"],
47
- "options": {
48
- "outputDir": "dist/storybook/@ks-digital/designsystem-angular",
49
- "configDir": "packages/angular/.storybook",
50
- "compodoc": false,
51
- "experimentalZoneless": true
52
- },
53
- "configurations": {
54
- "ci": {
55
- "quiet": true
56
- }
57
- }
58
- },
59
- "test-storybook": {
60
- "executor": "nx:run-commands",
61
- "options": {
62
- "command": "test-storybook -c packages/angular/.storybook --url=http://localhost:4400"
63
- }
64
- },
65
- "static-storybook": {
66
- "executor": "@nx/web:file-server",
67
- "dependsOn": ["build-storybook"],
68
- "options": {
69
- "buildTarget": "@ks-digital/designsystem-angular:build-storybook",
70
- "staticFilePath": "dist/storybook/@ks-digital/designsystem-angular",
71
- "spa": true,
72
- "experimentalZoneless": true
73
- },
74
- "configurations": {
75
- "ci": {
76
- "buildTarget": "@ks-digital/designsystem-angular:build-storybook:ci"
77
- }
78
- }
79
- }
80
- }
81
- }
@@ -1,46 +0,0 @@
1
- import { Meta, Canvas, Controls, Primary } from '@storybook/addon-docs/blocks'
2
-
3
- import * as AlertStories from './alert.stories'
4
-
5
- <Meta of={AlertStories} />
6
-
7
- # Alert
8
-
9
- Vi bruker `Alert` til å gi brukeren informasjon som det er ekstra viktig at de ser og forstår. Komponenten er designet for å fange brukernes oppmerksomhet. Teksten i varselet skal være kort og tydelig.
10
-
11
- <Primary />
12
- <Controls />
13
-
14
- ## Bruk
15
-
16
- ```tsx
17
- <ksd-alert>En beskjed det er viktig at brukeren ser</ksd-alert>
18
- ```
19
-
20
- ## Kodeeksempler
21
-
22
- `Alert` kan brukes til fire ulike budskap: Informasjon, suksess, advarsler og feilmelding.
23
-
24
- ### Informasjon
25
-
26
- Bruk `info` når du vil gi brukeren nøytral og nyttig informasjon.
27
-
28
- <Canvas of={AlertStories.VariantInfo} />
29
-
30
- ### Suksess
31
-
32
- Bruk `success` når du vil bekrefte at brukeren har fullført en oppgave, at handlingen var vellykket.
33
-
34
- <Canvas of={AlertStories.VariantSuccess} />
35
-
36
- ### Advarsel
37
-
38
- Bruk `warning` når du vil at brukeren skal foreta en bestemt handling eller for å advare dem om noe viktig.
39
-
40
- <Canvas of={AlertStories.VariantWarning} />
41
-
42
- ### Feilmelding
43
-
44
- Bruk `danger` for å informere om noe som er kritisk eller som hindrer brukeren i å komme videre.
45
-
46
- <Canvas of={AlertStories.VariantDanger} />
@@ -1,33 +0,0 @@
1
- import { NgStyle } from '@angular/common'
2
- import { render, screen } from '@testing-library/angular'
3
- import { Alert } from './alert'
4
-
5
- it('should render children, heading level 1', async () => {
6
- await render(
7
- `
8
- <ksd-alert color="info">
9
- <h1>Alert me!</h1>
10
- </ksd-alert>
11
- `,
12
- { imports: [Alert] },
13
- )
14
-
15
- expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent(
16
- 'Alert me!',
17
- )
18
- })
19
-
20
- it('style should be applied', async () => {
21
- await render(
22
- `
23
- <ksd-alert data-testid="alert" color="info" [ngStyle]="{ color: '#ffcc00' }" class="my-class">
24
- <h1>Alert me!</h1>
25
- </ksd-alert>
26
- `,
27
- { imports: [Alert, NgStyle] },
28
- )
29
-
30
- const alert = screen.getByTestId('alert')
31
- expect(alert).toHaveStyle({ color: '#ffcc00' })
32
- expect(alert).toHaveClass('my-class')
33
- })
@@ -1,138 +0,0 @@
1
- import { provideIcons } from '@ng-icons/core'
2
- import { phosphorPencilLine } from '@ng-icons/phosphor-icons/regular'
3
- import {
4
- componentWrapperDecorator,
5
- moduleMetadata,
6
- type Meta,
7
- type StoryObj,
8
- } from '@storybook/angular'
9
- import { CommonArgs } from '../../../.storybook/default-args'
10
- import { SeverityColors } from '../colors'
11
- import { Paragraph } from '../paragraph/paragraph'
12
- import { Alert } from './alert'
13
-
14
- const SEVERITY_COLORS: SeverityColors[] = [
15
- 'info',
16
- 'success',
17
- 'warning',
18
- 'danger',
19
- ]
20
-
21
- type AlertArgs = CommonArgs & {
22
- variant: 'default' | 'tinted'
23
- }
24
-
25
- const meta: Meta<AlertArgs> = {
26
- component: Alert,
27
- title: 'Komponenter/Alert',
28
- argTypes: {
29
- 'data-size': {
30
- options: ['sm', 'md', 'lg'],
31
- control: { type: 'radio' },
32
- },
33
- 'data-color': {
34
- options: SEVERITY_COLORS,
35
- control: { type: 'radio' },
36
- },
37
- },
38
- decorators: [
39
- moduleMetadata({
40
- imports: [Alert, Paragraph],
41
- providers: [provideIcons({ phosphorPencilLine })],
42
- }),
43
- componentWrapperDecorator(
44
- (story) =>
45
- `<div style="display:flex;flex-direction:row;justify-content:center;align-items:center;flex-wrap:wrap;gap:var(--ds-size-4)">${story}</div>`,
46
- ),
47
- ],
48
- }
49
- export default meta
50
- type Story = StoryObj<AlertArgs>
51
-
52
- export const Preview: Story = {
53
- render: (args) => ({
54
- props: args,
55
- template: `
56
- <ksd-alert>
57
- En beskjed det er viktig at brukeren ser
58
- </ksd-alert>
59
- `,
60
- }),
61
- }
62
-
63
- export const VariantInfo: Story = {
64
- args: {},
65
- render: (args) => ({
66
- props: args,
67
- template: `
68
- <ksd-alert data-color="info">
69
- <h2 class="ds-heading" data-size="xs" style="margin-bottom: var(--ds-size-2)">
70
- Har du husket å bestille passtime?
71
- </h2>
72
-
73
- <p ksd-paragraph>
74
- Det er lange køer for å bestille pass om dagen, det kan være lurt å
75
- bestille i god tid før du skal reise.
76
- </p>
77
- </ksd-alert>
78
- `,
79
- }),
80
- }
81
-
82
- export const VariantWarning: Story = {
83
- args: {},
84
- render: (args) => ({
85
- props: args,
86
- template: `
87
- <ksd-alert data-color="warning">
88
- <h2 class="ds-heading" data-size="xs" style="margin-bottom: var(--ds-size-2)">
89
- Vi har tekniske problemer
90
- </h2>
91
-
92
- <p ksd-paragraph>
93
- Det gjør at du kan bli avbrutt mens du fyller ut skjemaet. Vi jobber med å
94
- rette problemene.
95
- </p>
96
- </ksd-alert>
97
- `,
98
- }),
99
- }
100
-
101
- export const VariantDanger: Story = {
102
- args: {},
103
- render: (args) => ({
104
- props: args,
105
- template: `
106
- <ksd-alert data-color="danger">
107
- <h2 class="ds-heading" data-size="xs" style="margin-bottom: var(--ds-size-2)">
108
- Det har skjedd en feil
109
- </h2>
110
-
111
- <p ksd-paragraph>
112
- Vi klarer ikke å hente informasjonen du ser etter akkurat nå. Prøv igjen
113
- litt senere. Hvis vi fortsatt ikke klarer å vise informasjonen du trenger,
114
- tar du kontakt med kundeservice på telefon 85 44 32 66.
115
- </p>
116
- </ksd-alert>
117
- `,
118
- }),
119
- }
120
-
121
- export const VariantSuccess: Story = {
122
- args: {},
123
- render: (args) => ({
124
- props: args,
125
- template: `
126
- <ksd-alert data-color="success">
127
- <h2 class="ds-heading" data-size="xs" style="margin-bottom: var(--ds-size-2)">
128
- Gratulerer! Du kan nå starte selskapet ditt
129
- </h2>
130
-
131
- <p ksd-paragraph>
132
- Det ser ut til at regnestykket går i pluss og at du har det som skal til
133
- for å starte selskapet ditt.
134
- </p>
135
- </ksd-alert>
136
- `,
137
- }),
138
- }
@@ -1,46 +0,0 @@
1
- import { Component, input } from '@angular/core'
2
- import { SeverityColors } from '../colors'
3
- import { CommonInputs } from '../common-inputs'
4
-
5
- /**
6
- * Alerts are used to inform users about important information, warnings, errors, or success.
7
- */
8
- @Component({
9
- selector: 'ksd-alert',
10
- template: ` <ng-content />`,
11
- host: {
12
- class: 'ds-alert',
13
- },
14
- /**
15
- * Use Phosphor Icons
16
- */
17
- styles: `
18
- :host {
19
- --dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M128,24A104,104,0,1,0,232,128A104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z'/%3E%3C/svg%3E");
20
- }
21
- :host[data-color='warning'] {
22
- --dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M120,136V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0ZM232,91.55v72.9a15.86,15.86,0,0,1-4.69,11.31l-51.55,51.55A15.86,15.86,0,0,1,164.45,232H91.55a15.86,15.86,0,0,1-11.31-4.69L28.69,175.76A15.86,15.86,0,0,1,24,164.45V91.55a15.86,15.86,0,0,1,4.69-11.31L80.24,28.69A15.86,15.86,0,0,1,91.55,24h72.9a15.86,15.86,0,0,1,11.31,4.69l51.55,51.55A15.86,15.86,0,0,1,232,91.55Zm-16,0L164.45,40H91.55L40,91.55v72.9L91.55,216h72.9L216,164.45ZM128,160a12,12,0,1,0,12,12A12,12,0,0,0,128,160Z'/%3E%3C/svg%3E");
23
- }
24
-
25
- :host[data-color='success'] {
26
- --dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z'%3E%3C/path%3E%3C/svg%3E");
27
- }
28
-
29
- :host[data-color='danger'] {
30
- --dsc-alert-icon-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256'%3E%3Cpath d='M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z'%3E%3C/path%3E%3C/svg%3E");
31
- }
32
- `,
33
- hostDirectives: [
34
- {
35
- directive: CommonInputs,
36
- inputs: ['data-size'],
37
- },
38
- ],
39
- })
40
- export class Alert {
41
- /**
42
- * The color variant of the alert.
43
- */
44
- /* eslint-disable-next-line @angular-eslint/no-input-rename */
45
- dataColor = input<SeverityColors>(undefined, { alias: 'data-color' })
46
- }
@@ -1 +0,0 @@
1
- export { Alert } from './alert'
@@ -1,40 +0,0 @@
1
- import { Meta, Primary, Controls, Story } from '@storybook/addon-docs/blocks'
2
-
3
- import * as ButtonStories from './button.stories'
4
-
5
- <Meta of={ButtonStories} />
6
-
7
- # Button
8
-
9
- Knappar lèt brukarane utføre handlingar.
10
-
11
- <Primary />
12
- <Controls />
13
-
14
- ## Ikoner
15
-
16
- - [Unngå å bruke ikonfonter](https://www.irigoyen.dev/blog/2021/02/17/stop-using-icon-fonts/).
17
- - For Angular kan du bruke [Ng Icons](https://ng-icons.github.io/ng-icons), et bibliotek som inneholder ikoner fra Phosphor Icons og Material Icons – de to ikonsettene vi offisielt støtter i våre løsninger.
18
-
19
- ### Egne ikoner
20
-
21
- Du kan også bruke SVG-markup direkte, f.eks. hvis du har egne ikoner.
22
-
23
- ```tsx
24
- <button ksd-button>
25
- <svg
26
- xmlns="http://www.w3.org/2000/svg"
27
- width="1em"
28
- height="1em"
29
- viewBox="0 0 24 24"
30
- fill="none"
31
- stroke="currentColor"
32
- aria-hidden="true"
33
- >
34
- <path d="M3 11.5L12 4l9 7.5" />
35
- <path d="M5 10.5v9.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-9.5" />
36
- <path d="M10 21v-5a2 2 0 0 1 4 0v5" />
37
- </svg>
38
- Eget SVG-ikon
39
- </button>
40
- ```
@@ -1,86 +0,0 @@
1
- import { render, screen } from '@testing-library/angular'
2
- import userEvent from '@testing-library/user-event'
3
- import { vi } from 'vitest'
4
- import { Button } from './button'
5
-
6
- it('should render as aria-disabled when aria-disabled is true regardless of variant', async () => {
7
- await render(
8
- `
9
- <button ksd-button aria-disabled="true">My button</button>
10
- `,
11
- { imports: [Button] },
12
- )
13
-
14
- const button = screen.getByRole('button')
15
- expect(button).toHaveAttribute('aria-disabled')
16
- })
17
-
18
- it('should render as disabled when disabled is true regardless of variant', async () => {
19
- await render(
20
- `
21
- <button ksd-button disabled>My button</button>
22
- `,
23
- { imports: [Button] },
24
- )
25
-
26
- const button = screen.getByRole('button')
27
- expect(button).toBeDisabled()
28
- })
29
-
30
- it('should be clickable', async () => {
31
- const handleClick = vi.fn()
32
-
33
- await render(
34
- `<button ksd-button (click)="handleClick()">My button</button>`,
35
- {
36
- imports: [Button],
37
- componentProperties: { handleClick },
38
- },
39
- )
40
- const user = userEvent.setup()
41
- const button = screen.getByRole('button')
42
-
43
- await user.click(button)
44
- expect(handleClick).toHaveBeenCalledTimes(1)
45
- })
46
-
47
- it('should not be clickable when disabled', async () => {
48
- const handleClick = vi.fn()
49
-
50
- await render(
51
- `<button ksd-button disabled (click)="handleClick()">My button</button>`,
52
- {
53
- imports: [Button],
54
- componentProperties: { handleClick },
55
- },
56
- )
57
- const user = userEvent.setup()
58
- const button = screen.getByRole('button')
59
-
60
- await user.click(button)
61
- expect(handleClick).not.toHaveBeenCalled()
62
- })
63
-
64
- it('should render button text', async () => {
65
- await render(
66
- `
67
- <button ksd-button disabled>Different button text</button>
68
- `,
69
- { imports: [Button] },
70
- )
71
-
72
- const button = screen.getByRole('button', { name: 'Different button text' })
73
- expect(button).toBeInTheDocument()
74
- })
75
-
76
- it('should set aria-busy when loading', async () => {
77
- await render(
78
- `
79
- <button ksd-button loading>My button</button>
80
- `,
81
- { imports: [Button] },
82
- )
83
-
84
- const button = screen.getByRole('button')
85
- expect(button).toHaveAttribute('aria-busy', 'true')
86
- })