Skip to content

Commit f395512

Browse files
committed
theme and layout acccross all components
1 parent 42f4944 commit f395512

6 files changed

Lines changed: 38 additions & 1 deletion

File tree

src/v2/components/footer/Footer.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,26 @@ describe('SolidUIFooterElement', () => {
3737

3838
currentUserSpy.mockRestore()
3939
})
40+
41+
it('defaults layout to desktop', async () => {
42+
const footer = new Footer()
43+
document.body.appendChild(footer)
44+
await footer.updateComplete
45+
46+
expect(footer.layout).toBe('desktop')
47+
expect(footer.getAttribute('layout')).toBe('desktop')
48+
})
49+
50+
it('applies mobile layout styles by removing border, box-shadow and border-radius', async () => {
51+
const footer = new Footer()
52+
footer.layout = 'mobile'
53+
document.body.appendChild(footer)
54+
await footer.updateComplete
55+
56+
const style = footer.shadowRoot?.querySelector('style')?.textContent
57+
expect(style).toContain(':host([layout=\'mobile\'])')
58+
expect(style).toContain('border: none;')
59+
expect(style).toContain('box-shadow: none;')
60+
expect(footer.getAttribute('layout')).toBe('mobile')
61+
})
4062
})

src/v2/components/footer/Footer.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getName } from '../../../utils/headerFooterHelpers'
66
export class Footer extends LitElement {
77
static properties = {
88
theme: { type: String, reflect: true },
9+
layout: { type: String, reflect: true },
910
position: { type: String, reflect: true },
1011
top: { type: String, reflect: true },
1112
right: { type: String, reflect: true },
@@ -63,9 +64,16 @@ export class Footer extends LitElement {
6364
display: block;
6465
margin-bottom: 0.5rem;
6566
}
67+
68+
:host([layout='mobile']) {
69+
border: none;
70+
box-shadow: none;
71+
border-radius: 0;
72+
}
6673
`
6774

6875
declare theme: 'light' | 'dark'
76+
declare layout: 'desktop' | 'mobile'
6977
declare position: 'static' | 'absolute' | 'relative' | 'fixed' | 'sticky'
7078
declare top: string
7179
declare right: string
@@ -77,6 +85,7 @@ export class Footer extends LitElement {
7785
constructor () {
7886
super()
7987
this.theme = 'light'
88+
this.layout = 'desktop'
8089
this.position = 'static'
8190
this.top = 'auto'
8291
this.right = 'auto'

src/v2/components/footer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ footer.bottom = '1rem'
5959

6060
Properties / attributes:
6161

62+
- `layout`: `desktop` (default) or `mobile`. In mobile layout, the border, box-shadow and border-radius are removed.
6263
- `position`: `static`, `absolute`, `relative`, `fixed`, or `sticky`.
6364
- `top`: CSS offset for the top edge when `position` is not `static`.
6465
- `right`: CSS offset for the right edge when `position` is not `static`.

src/v2/components/header/Header.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ export class Header extends LitElement {
645645
<solid-ui-login-button
646646
label="${this.loginAction.label}"
647647
icon=${ifDefined(this.layout !== 'mobile' ? (this.loginIcon || this.loginAction.icon) : undefined)}
648+
layout="${this.layout}"
648649
theme="${this.theme}"
649650
part="login-action"
650651
@login-success="${() => this.handleLoginSuccess()}"

src/v2/components/loginButton/LoginButton.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class LoginButton extends LitElement {
88
theme: { type: String, reflect: true },
99
issuerUrl: { type: String, attribute: 'issuer-url', reflect: true },
1010
icon: { type: String, reflect: true },
11+
layout: { type: String, reflect: true },
1112
_popupOpen: { state: true },
1213
_issuerInputValue: { state: true },
1314
_dropdownOpen: { state: true }
@@ -309,6 +310,7 @@ export class LoginButton extends LitElement {
309310
declare theme: 'light' | 'dark'
310311
declare issuerUrl: string
311312
declare icon: string
313+
declare layout: 'desktop' | 'mobile'
312314
declare _popupOpen: boolean
313315
declare _issuerInputValue: string
314316
declare _dropdownOpen: boolean
@@ -322,6 +324,7 @@ export class LoginButton extends LitElement {
322324
this.theme = 'light'
323325
this.issuerUrl = ''
324326
this.icon = ''
327+
this.layout = 'desktop'
325328
this._popupOpen = false
326329
this._issuerInputValue = ''
327330
this._dropdownOpen = false

src/v2/components/loginButton/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ btn.addEventListener('login-success', (e: CustomEvent) => {
5555
| `label` | `label` | `string` | `Log In` | Button text. Overridable via the default slot. |
5656
| `issuerUrl` | `issuer-url` | `string` | `''` | Pre-fills the IDP URL input in the popup. If `localStorage.loginIssuer` is set it takes precedence. |
5757
| `icon` | `icon` | `string` | `''` | URL of a decorative icon displayed on the left side of the button text. When used inside `<solid-ui-header layout="mobile">`, the header suppresses the icon. |
58+
| `layout` | `layout` | `'desktop' \| 'mobile'` | `'desktop'` | When set to `mobile`, removes the button border for a compact header appearance. |
5859
| `theme` | `theme` | `'light' \| 'dark'` | `'light'` | Sets the colour theme. Use `'dark'` when placing the button on a dark background. |
5960

6061
### Events
@@ -98,7 +99,7 @@ Set `theme="dark"` for dark backgrounds. The button background (`--primary-royal
9899
<solid-ui-login-button theme="dark"></solid-ui-login-button>
99100
```
100101

101-
When used inside `<solid-ui-header>`, the theme attribute is forwarded automatically. When the header is in `mobile` layout, its built-in login button suppresses the `icon`.
102+
When used inside `<solid-ui-header>`, the theme attribute is forwarded automatically. When the header is in `mobile` layout, its built-in login button suppresses the `icon`. When the `layout` attribute is set to `mobile`, the button renders without a border for a cleaner compact mobile/header presentation.
102103

103104
## Popup behaviour
104105

0 commit comments

Comments
 (0)