@sb1/ffe-modals-react 100.8.2 → 100.9.0

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 (2) hide show
  1. package/README.md +110 -11
  2. package/package.json +5 -5
package/README.md CHANGED
@@ -1,21 +1,122 @@
1
1
  # @sb1/ffe-modals-react
2
2
 
3
- ## Install
3
+ ## Installasjon
4
4
 
5
- ```
5
+ ```bash
6
6
  npm install --save @sb1/ffe-modals-react
7
7
  ```
8
8
 
9
- ## Usage
9
+ ## Bruk
10
+
11
+ Full dokumentasjon: https://sparebank1.github.io/designsystem/
12
+
13
+ Avhengig av `@sb1/ffe-icons-react` og `@sb1/ffe-buttons-react`.
14
+
15
+ ```css
16
+ @import '@sb1/ffe-modals/css/modals.css';
17
+ ```
18
+
19
+ ## Beskrivelse
20
+
21
+ Modal-komponenter for korte, fokuserte interaksjoner. Bruk for enkle oppgaver, bekreftelser eller informasjon. Ikke bruk på mobil - bruk ark/sheets.
22
+
23
+ Bruk når: Enkelt steg, tydelig fokus, avbrytbar interaksjon.
24
+ Ikke bruk for: Lange/flerstegsprosesser eller primær navigasjon.
25
+
26
+ ### Eksporterte komponenter og typer
27
+
28
+ ```tsx
29
+ import {
30
+ Modal,
31
+ ModalHandle,
32
+ ModalProps,
33
+ ModalBlock,
34
+ } from '@sb1/ffe-modals-react';
35
+ ```
36
+
37
+ | Eksport | Type | Beskrivelse |
38
+ | ------------- | --------- | ------------------------------------------------ |
39
+ | `Modal` | Component | Hovedkomponenten for modal-dialog |
40
+ | `ModalHandle` | Type | TypeScript-type for ref-objektet som eksponeres |
41
+ | `ModalProps` | Type | TypeScript-type for Modal-komponentens props |
42
+ | `ModalBlock` | Component | Wrapper-komponent for innhold med riktig padding |
10
43
 
11
- Full documentation on lists usage is available at https://design.sparebank1.no/komponenter/modal/.
44
+ ## Eksempler
12
45
 
13
- This package depends on `@sb1/ffe-icons-react`.
14
- Make sure you import the less-files.
46
+ ### Grunnleggende bruk
15
47
 
16
- ## Development
48
+ ```tsx
49
+ import React, { useRef } from 'react';
50
+ import { Modal, ModalHandle, ModalBlock } from '@sb1/ffe-modals-react';
51
+ import {
52
+ ActionButton,
53
+ SecondaryButton,
54
+ ButtonGroup,
55
+ } from '@sb1/ffe-buttons-react';
56
+ import { Heading2, Paragraph } from '@sb1/ffe-core-react';
17
57
 
18
- To start a local development server, run the following from the designsystem root folder:
58
+ export function ModalExample() {
59
+ const modalRef = useRef<ModalHandle>(null);
60
+
61
+ return (
62
+ <>
63
+ <ActionButton onClick={() => modalRef.current?.open()}>
64
+ Åpne modal
65
+ </ActionButton>
66
+
67
+ <Modal
68
+ ref={modalRef}
69
+ ariaLabelledby="modal-heading"
70
+ locale="nb"
71
+ onClose={() => console.log('Lukket')}
72
+ >
73
+ <ModalBlock>
74
+ <Heading2 id="modal-heading">Bekreft handling</Heading2>
75
+ <Paragraph>Er du sikker på at du vil fortsette?</Paragraph>
76
+ <ButtonGroup thin={true} ariaLabel="Handlingsknapper">
77
+ <SecondaryButton
78
+ onClick={() => modalRef.current?.close()}
79
+ >
80
+ Avbryt
81
+ </SecondaryButton>
82
+ <ActionButton autoFocus={true}>Bekreft</ActionButton>
83
+ </ButtonGroup>
84
+ </ModalBlock>
85
+ </Modal>
86
+ </>
87
+ );
88
+ }
89
+ ```
90
+
91
+ ### Tilpasset innhold (med bilde eller grafikk)
92
+
93
+ Innhold utenfor `ModalBlock` får ingen padding (nyttig for bilder/grafikk):
94
+
95
+ ```tsx
96
+ <Modal ref={modalRef} ariaLabelledby={headingId}>
97
+ <div
98
+ style={{
99
+ height: 150,
100
+ width: '100%',
101
+ background: 'var(--ffe-color-surface-secondary-default)',
102
+ }}
103
+ />
104
+ <ModalBlock>
105
+ <Heading2 id={headingId}>Modal med bilde</Heading2>
106
+ <Paragraph>Innhold her får padding.</Paragraph>
107
+ </ModalBlock>
108
+ </Modal>
109
+ ```
110
+
111
+ ### Dark mode
112
+
113
+ Legg til `className="ffe-dark"` for dark mode.
114
+
115
+ ### Sjekke om modal er åpen
116
+
117
+ Bruk `modalRef.current?.isOpen` for å sjekke tilstand.
118
+
119
+ ## Utvikling
19
120
 
20
121
  ```bash
21
122
  npm install
@@ -23,6 +124,4 @@ npm run build
23
124
  npm start
24
125
  ```
25
126
 
26
- A local instance of `Storybook` with live reloading will run at http://localhost:6006/.
27
-
28
- Example implementations using the latest versions of all components are also available at https://sparebank1.github.io/designsystem.
127
+ Lokal Storybook kjører på http://localhost:6006/.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sb1/ffe-modals-react",
3
- "version": "100.8.2",
3
+ "version": "100.9.0",
4
4
  "license": "MIT",
5
5
  "author": "SpareBank 1",
6
6
  "files": [
@@ -24,13 +24,13 @@
24
24
  "test:watch": "ffe-buildtool jest --watch"
25
25
  },
26
26
  "dependencies": {
27
- "@sb1/ffe-icons-react": "^100.8.2",
28
- "@sb1/ffe-modals": "^100.8.2",
27
+ "@sb1/ffe-icons-react": "^100.9.0",
28
+ "@sb1/ffe-modals": "^100.9.0",
29
29
  "classnames": "^2.5.1",
30
30
  "dialog-polyfill": "^0.5.6"
31
31
  },
32
32
  "devDependencies": {
33
- "@sb1/ffe-buildtool": "^100.8.2",
33
+ "@sb1/ffe-buildtool": "^100.9.0",
34
34
  "eslint": "^9.22.0",
35
35
  "react": "^18.2.0",
36
36
  "react-dom": "^18.2.0"
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "50fbbbdb2023a60add7158e8c5bd6443c4f9c95e"
44
+ "gitHead": "41f20cf10bec5ebe53036c282690983d2114fb45"
45
45
  }