@sb1/ffe-collapse-react 100.8.3 → 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.
- package/README.md +68 -23
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,42 +1,87 @@
|
|
|
1
1
|
# @sb1/ffe-collapse-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Beskrivelse
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
React-komponent for å vise og skjule innhold med animasjon. Bruker CSS grid-animasjon for jevn overgang mellom åpent og lukket tilstand.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installasjon
|
|
8
|
+
|
|
9
|
+
```bash
|
|
8
10
|
npm install --save @sb1/ffe-collapse-react
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Bruk
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Dokumentasjon: https://sparebank1.github.io/designsystem/
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
This can preferably be done by importing the less-file from the less-folder
|
|
17
|
-
in the package.\
|
|
18
|
-
Alternatively you can do it by adding style to the class
|
|
19
|
-
`.ffe-collapse-transition`\, adding it to your own class and provide the class
|
|
20
|
-
through the `className` property or by styling it directly through the `style` property.
|
|
17
|
+
### Importere CSS
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
```css
|
|
20
|
+
@import '@sb1/ffe-collapse-react/css/collapse.css';
|
|
21
|
+
```
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
Merk: CSS-variablene `--ffe-transition-duration` og `--ffe-ease` må være definert (tilgjengelig via `@sb1/ffe-core`).
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
## Eksempler
|
|
26
|
+
|
|
27
|
+
### Grunnleggende bruk
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Collapse } from '@sb1/ffe-collapse-react';
|
|
31
|
+
import { useState } from 'react';
|
|
32
|
+
|
|
33
|
+
function BasicExample() {
|
|
34
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div>
|
|
38
|
+
<button onClick={() => setIsOpen(!isOpen)}>
|
|
39
|
+
{isOpen ? 'Skjul' : 'Vis'} innhold
|
|
40
|
+
</button>
|
|
41
|
+
<Collapse isOpen={isOpen}>
|
|
42
|
+
<p>Dette innholdet kan vises og skjules</p>
|
|
43
|
+
</Collapse>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
28
47
|
```
|
|
29
48
|
|
|
30
|
-
|
|
49
|
+
### Med ExpandButton
|
|
31
50
|
|
|
32
|
-
|
|
51
|
+
```tsx
|
|
52
|
+
import { Collapse } from '@sb1/ffe-collapse-react';
|
|
53
|
+
import { ExpandButton } from '@sb1/ffe-buttons-react';
|
|
54
|
+
import { useState } from 'react';
|
|
33
55
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
function ExpandButtonExample() {
|
|
57
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
<ExpandButton
|
|
62
|
+
isExpanded={isOpen}
|
|
63
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
64
|
+
>
|
|
65
|
+
{isOpen ? 'Skjul' : 'Vis'} detaljer
|
|
66
|
+
</ExpandButton>
|
|
67
|
+
<Collapse isOpen={isOpen}>
|
|
68
|
+
<p>Detaljert informasjon her</p>
|
|
69
|
+
</Collapse>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
38
73
|
```
|
|
39
74
|
|
|
40
|
-
|
|
75
|
+
## TypeScript
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import type { CollapseProps } from '@sb1/ffe-collapse-react';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Utvikling
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install && npm run build && npm start
|
|
85
|
+
```
|
|
41
86
|
|
|
42
|
-
|
|
87
|
+
Storybook kjører på http://localhost:6006/.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-collapse-react",
|
|
3
|
-
"version": "100.
|
|
3
|
+
"version": "100.9.0",
|
|
4
4
|
"description": "React component for expand/collapse",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ffe"
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"test:watch": "ffe-buildtool jest --watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@sb1/ffe-core": "^100.
|
|
33
|
+
"@sb1/ffe-core": "^100.9.0",
|
|
34
34
|
"classnames": "^2.3.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@sb1/ffe-buildtool": "^100.
|
|
37
|
+
"@sb1/ffe-buildtool": "^100.9.0",
|
|
38
38
|
"eslint": "^9.22.0",
|
|
39
39
|
"react": "^18.2.0",
|
|
40
40
|
"react-dom": "^18.2.0"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "41f20cf10bec5ebe53036c282690983d2114fb45"
|
|
49
49
|
}
|