@oslokommune/punkt-react 13.19.2 → 13.21.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/CHANGELOG.md +36 -0
- package/dist/index.d.ts +2 -0
- package/dist/punkt-react.es.js +819 -771
- package/dist/punkt-react.umd.js +118 -110
- package/package.json +4 -4
- package/src/components/button/Button.test.tsx +64 -0
- package/src/components/button/Button.tsx +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.21.0",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
41
41
|
"@lit/react": "^1.0.7",
|
|
42
|
-
"@oslokommune/punkt-elements": "^13.
|
|
42
|
+
"@oslokommune/punkt-elements": "^13.21.0",
|
|
43
43
|
"classnames": "^2.5.1",
|
|
44
44
|
"prettier": "^3.3.3",
|
|
45
45
|
"react-hook-form": "^7.53.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
|
|
49
49
|
"@oslokommune/punkt-assets": "^13.16.0",
|
|
50
|
-
"@oslokommune/punkt-css": "^13.
|
|
50
|
+
"@oslokommune/punkt-css": "^13.21.0",
|
|
51
51
|
"@testing-library/jest-dom": "^6.5.0",
|
|
52
52
|
"@testing-library/react": "^16.0.1",
|
|
53
53
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
104
104
|
},
|
|
105
105
|
"license": "MIT",
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "7559532feebf044efeec97d19d74c9c77e46a5b3"
|
|
107
107
|
}
|
|
@@ -127,3 +127,67 @@ describe('accessibility', () => {
|
|
|
127
127
|
expect(results).toHaveNoViolations()
|
|
128
128
|
})
|
|
129
129
|
})
|
|
130
|
+
|
|
131
|
+
describe('PktButton icon paths', () => {
|
|
132
|
+
test('passes iconPath to PktIcon when provided', () => {
|
|
133
|
+
const customPath = 'https://custom-cdn.example.com/icons/'
|
|
134
|
+
render(
|
|
135
|
+
<PktButton variant="icon-left" iconName="user" iconPath={customPath}>
|
|
136
|
+
Test Button
|
|
137
|
+
</PktButton>,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
const icon = document.querySelector('.pkt-btn__icon:not(.pkt-btn__spinner)') as HTMLElement & { path?: string }
|
|
141
|
+
expect(icon?.path).toBe(customPath)
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
test('does not set path property when iconPath is not provided', () => {
|
|
145
|
+
render(
|
|
146
|
+
<PktButton variant="icon-left" iconName="user">
|
|
147
|
+
Test Button
|
|
148
|
+
</PktButton>,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const icon = document.querySelector('.pkt-btn__icon:not(.pkt-btn__spinner)') as HTMLElement & { path?: string }
|
|
152
|
+
// When not provided, path uses PktIcon's default
|
|
153
|
+
expect(icon?.path).toBe('https://punkt-cdn.oslo.kommune.no/latest/icons/')
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('passes secondIconPath to second PktIcon when provided', () => {
|
|
157
|
+
const customPath = 'https://custom-cdn.example.com/icons/'
|
|
158
|
+
render(
|
|
159
|
+
<PktButton variant="icons-right-and-left" iconName="home" secondIconName="star" secondIconPath={customPath}>
|
|
160
|
+
Test Button
|
|
161
|
+
</PktButton>,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
const icons = document.querySelectorAll('.pkt-btn__icon:not(.pkt-btn__spinner)') as NodeListOf<
|
|
165
|
+
HTMLElement & { path?: string }
|
|
166
|
+
>
|
|
167
|
+
expect(icons).toHaveLength(2)
|
|
168
|
+
expect(icons[1]?.path).toBe(customPath)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
test('handles both iconPath and secondIconPath independently', () => {
|
|
172
|
+
const iconPath = 'https://custom-cdn.example.com/icons/'
|
|
173
|
+
const secondIconPath = 'https://another-cdn.example.com/icons/'
|
|
174
|
+
render(
|
|
175
|
+
<PktButton
|
|
176
|
+
variant="icons-right-and-left"
|
|
177
|
+
iconName="home"
|
|
178
|
+
secondIconName="star"
|
|
179
|
+
iconPath={iconPath}
|
|
180
|
+
secondIconPath={secondIconPath}
|
|
181
|
+
>
|
|
182
|
+
Test Button
|
|
183
|
+
</PktButton>,
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
const icons = document.querySelectorAll('.pkt-btn__icon:not(.pkt-btn__spinner)') as NodeListOf<
|
|
187
|
+
HTMLElement & { path?: string }
|
|
188
|
+
>
|
|
189
|
+
expect(icons).toHaveLength(2)
|
|
190
|
+
expect(icons[0]?.path).toBe(iconPath)
|
|
191
|
+
expect(icons[1]?.path).toBe(secondIconPath)
|
|
192
|
+
})
|
|
193
|
+
})
|
|
@@ -14,6 +14,8 @@ window.pktAnimationPath = window.pktAnimationPath || 'https://punkt-cdn.oslo.kom
|
|
|
14
14
|
export interface IPktButton extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
15
15
|
iconName?: string
|
|
16
16
|
secondIconName?: string
|
|
17
|
+
iconPath?: string
|
|
18
|
+
secondIconPath?: string
|
|
17
19
|
mode?: 'light' | 'dark'
|
|
18
20
|
size?: 'small' | 'medium' | 'large'
|
|
19
21
|
fullWidth?: boolean
|
|
@@ -46,6 +48,8 @@ export const PktButton = forwardRef(
|
|
|
46
48
|
className,
|
|
47
49
|
iconName = 'user',
|
|
48
50
|
secondIconName = 'user',
|
|
51
|
+
iconPath,
|
|
52
|
+
secondIconPath,
|
|
49
53
|
size = 'medium',
|
|
50
54
|
fullWidth = false,
|
|
51
55
|
fullWidthOnMobile = false,
|
|
@@ -89,9 +93,17 @@ export const PktButton = forwardRef(
|
|
|
89
93
|
{isLoading && (
|
|
90
94
|
<PktIcon className="pkt-btn__icon pkt-btn__spinner" name="spinner-blue" path={loadingAnimationPath} />
|
|
91
95
|
)}
|
|
92
|
-
{variant !== 'label-only' &&
|
|
96
|
+
{variant !== 'label-only' && (
|
|
97
|
+
<PktIcon className="pkt-btn__icon" name={iconName} {...(iconPath && { path: iconPath })}></PktIcon>
|
|
98
|
+
)}
|
|
93
99
|
<span className="pkt-btn__text">{children}</span>
|
|
94
|
-
{variant === 'icons-right-and-left' &&
|
|
100
|
+
{variant === 'icons-right-and-left' && (
|
|
101
|
+
<PktIcon
|
|
102
|
+
className="pkt-btn__icon"
|
|
103
|
+
name={secondIconName}
|
|
104
|
+
{...(secondIconPath && { path: secondIconPath })}
|
|
105
|
+
></PktIcon>
|
|
106
|
+
)}
|
|
95
107
|
</button>
|
|
96
108
|
)
|
|
97
109
|
},
|