generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(LUX-13): rename login-method-button to button-login (#41)
BREAKING CHANGE: the component is no longer available under the original name `login-method-button` but rather under its new name `button-login` BREAKING CHANGE: the `variant` property for the button-login is renamed to `agent` --------- Co-authored-by: Raoul <85627716+rwittenberns@users.noreply.github.com>
- Loading branch information
1 parent
a9f405a
commit 5d3e9e8
Showing
20 changed files
with
170 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Button Login | ||
|
||
De Button Login is een knop die specifiek bedoeld is voor de Inlogstraat. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<button class="lux-button-login lux-button-login__icon--[agent]"> | ||
<span class="lux-button-login__label"></span> | ||
<div class="lux-button-login__icon" aria-hidden="true"></div> | ||
</button> |
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
packages/components-css/login-method-button/login-method-button.html
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
// import { createReactComponent } from './react-component-lib'; | ||
|
||
export * from './components'; | ||
// export const ExampleButton = /*@__PURE__*/ createReactComponent('lux-button'); |
File renamed without changes.
57 changes: 57 additions & 0 deletions
57
packages/web-components-stencil/src/components/button-login/button-login.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
:host { | ||
appearance: button; | ||
display: contents; | ||
} | ||
|
||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
|
||
.lux-button-login { | ||
align-items: center; | ||
appearance: button; | ||
background-color: var(--lux-button-login-background); | ||
border-color: var(--lux-button-login-border-color); | ||
border-radius: var(--lux-button-login-border-radius); | ||
border-style: var(--lux-button-login-border-style); | ||
border-width: var(--lux-button-login-border-width); | ||
color: var(--lux-button-login-color); | ||
display: flex; | ||
font-family: var(--lux-button-login-font-family); | ||
font-size: var(--lux-button-login-font-size); | ||
font-weight: var(--lux-button-login-font-weight); | ||
gap: var(--lux-button-login-gap); | ||
justify-content: space-between; | ||
line-height: var(--lux-font-line-height-m); | ||
margin-block: 0; | ||
margin-inline: 0; | ||
min-block-size: var(--lux-button-login-min-block-size); | ||
min-inline-size: var(--lux-button-login-min-inline-size); | ||
padding-block-end: var(--lux-button-login-padding-block-end); | ||
padding-block-start: var(--lux-button-login-padding-block-start); | ||
padding-inline-end: var(--lux-button-login-padding-inline-end); | ||
padding-inline-start: var(--lux-button-login-padding-inline-start); | ||
user-select: none; | ||
} | ||
|
||
.lux-button-login:focus-visible { | ||
outline-color: var(--lux-button-login-focus-outline-color); | ||
outline-offset: var(--lux-button-login-focus-outline-offset); | ||
outline-style: var(--lux-button-login-focus-outline-style); | ||
outline-width: var(--lux-button-login-focus-outline-width); | ||
} | ||
|
||
.lux-button-login:hover { | ||
background-color: var(--lux-button-login-hover-background); | ||
} | ||
|
||
.lux-button-login:active { | ||
background-color: var(--lux-button-login-active-background); | ||
border-color: var(--lux-button-login-active-border-color); | ||
} | ||
|
||
.lux-button-login__logo { | ||
block-size: var(--lux-button-login-icon-size); | ||
inline-size: var(--lux-button-login-icon-size); | ||
line-height: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/web-components-stencil/src/components/button-login/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { ButtonLoginAgent } from './types'; | ||
|
||
export const COMPONENT_TAG = 'lux-button-login'; | ||
|
||
export const LoginAgentsLabels: Record<ButtonLoginAgent, string> = { | ||
digid: 'Inloggen', | ||
'digid-machtigen': 'Inloggen als gemachtigde', | ||
eherkenning: 'Inloggen als bedrijf of instelling', | ||
eidas: 'European login', | ||
}; |
6 changes: 3 additions & 3 deletions
6
...gin-method-button/test/unit/a11y.spec.tsx → ...ents/button-login/test/unit/a11y.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/web-components-stencil/src/components/button-login/test/unit/button-login.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { expect, it, jest } from '@jest/globals'; | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { getTestableShadowElement } from '../../../../utils/test/element'; | ||
import { ButtonLogin } from '../../button-login'; | ||
import { ButtonLoginAgent } from '../../types'; | ||
|
||
interface AgentTestConfig { | ||
label: string; | ||
agent: ButtonLoginAgent; | ||
} | ||
|
||
const agents: AgentTestConfig[] = [ | ||
{ agent: 'digid', label: 'Inloggen' }, | ||
{ agent: 'digid-machtigen', label: 'Inloggen als gemachtigde' }, | ||
{ agent: 'eherkenning', label: 'Inloggen als bedrijf of instelling' }, | ||
{ agent: 'eidas', label: 'European login' }, | ||
]; | ||
|
||
it.each(agents)( | ||
'renders the correct icon and label for [agent="$agent"]', | ||
async ({ agent, label }: AgentTestConfig) => { | ||
const page = await newSpecPage({ | ||
components: [ButtonLogin], | ||
html: `<lux-button-login agent="${agent}" />`, | ||
}); | ||
|
||
const labelElement = getTestableShadowElement<HTMLSpanElement>(page, 'label'); | ||
const logoContainerElement = getTestableShadowElement<HTMLDivElement>(page, `logo`); | ||
|
||
expect(labelElement.textContent).toBe(label); | ||
// TODO check for the child to be an SVGElement with [data-testid="icon-${agent}"] | ||
// --> logoContainerElement.children[0] is an empty object | ||
expect(logoContainerElement.children).toHaveLength(1); | ||
}, | ||
); | ||
|
||
it('allows for a custom label to be provided', async () => { | ||
const page = await newSpecPage({ | ||
components: [ButtonLogin], | ||
html: `<lux-button-login agent="digid" label="My Custom Label" />`, | ||
}); | ||
|
||
const { textContent }: HTMLLuxButtonLoginElement = getTestableShadowElement(page, 'label'); | ||
expect(textContent).toBe('My Custom Label'); | ||
}); | ||
|
||
it('only emits a luxClick event when clicked', async () => { | ||
const page = await newSpecPage({ | ||
components: [ButtonLogin], | ||
html: `<lux-button-login agent="digid" />`, | ||
}); | ||
|
||
const clickHandler = jest.fn(); | ||
const luxClickHandler = jest.fn(); | ||
const buttonLogin = page.root; | ||
|
||
buttonLogin?.addEventListener('click', luxClickHandler); | ||
buttonLogin?.addEventListener('luxClick', luxClickHandler); | ||
|
||
buttonLogin?.click(); | ||
|
||
expect(clickHandler).not.toHaveBeenCalled(); | ||
expect(luxClickHandler).toHaveBeenCalled(); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/web-components-stencil/src/components/button-login/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type ButtonLoginAgent = 'digid' | 'digid-machtigen' | 'eidas' | 'eherkenning'; |
10 changes: 0 additions & 10 deletions
10
packages/web-components-stencil/src/components/login-method-button/constants.ts
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
packages/web-components-stencil/src/components/login-method-button/login-method-button.css
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.