Skip to content

Commit 584823d

Browse files
committed
use theme detection mixin to automatically apply Lumo theme
1 parent 31eda63 commit 584823d

File tree

5 files changed

+32
-29
lines changed

5 files changed

+32
-29
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ Add `<vcf-breadcrumbs>` element to the page. Inside added element add few `<vcf-
3737

3838
## Updates since version 3.0.0
3939

40-
By default, the component uses a minimal set of functional styles that provide a foundation for a custom theme.
41-
To use the component with the Vaadin Lumo theme, import the component's Lumo theme from `@vaadin-component-factory/vcf-breadcrumb/theme/lumo.css`.
40+
When the application does not load the Aura or Lumo theme, the component uses a minimal set of functional styles that provide a foundation for a custom theme.
4241

4342
`ThemableMixin` has been removed from the component, and injecting styles into the component's shadow root using `registerStyles` is no longer supported.
4443
Use global CSS to style the component using part names and CSS variables instead.

demo/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<script dev src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
88
<script dev type="module" src="demo.js"></script>
99
<link rel="stylesheet" href="/node_modules/@vaadin/vaadin-lumo-styles/lumo.css" />
10-
<link rel="stylesheet" href="/theme/lumo.css" />
1110
<custom-style>
1211
<style is="custom-style" include="demo-pages-shared-styles">
1312
.centered {

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@
4444
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
4545
},
4646
"dependencies": {
47-
"@vaadin/component-base": "^25.0.0-beta1",
48-
"@vaadin/popover": "^25.0.0-beta1",
49-
"@vaadin/vertical-layout": "^25.0.0-beta1",
47+
"@vaadin/component-base": "^25.0.0-beta2",
48+
"@vaadin/popover": "^25.0.0-beta2",
49+
"@vaadin/vertical-layout": "^25.0.0-beta2",
50+
"@vaadin/vaadin-themable-mixin": "^25.0.0-beta2",
5051
"lit": "^3.0.0"
5152
},
5253
"devDependencies": {
@@ -58,7 +59,7 @@
5859
"@types/jest": "^29.5.14",
5960
"@typescript-eslint/eslint-plugin": "^5.48.0",
6061
"@typescript-eslint/parser": "^5.48.0",
61-
"@vaadin/vaadin-lumo-styles": "^25.0.0-beta1",
62+
"@vaadin/vaadin-lumo-styles": "^25.0.0-beta2",
6263
"@web/dev-server": "^0.4.3",
6364
"@web/test-runner": "^0.19.0",
6465
"@webcomponents/webcomponentsjs": "^2.0.0",

src/component/vcf-breadcrumb.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
* limitations under the License.
1717
* #L%
1818
*/
19-
import { html, LitElement, css } from "lit";
19+
import { LitElement, css, html } from "lit";
2020
import { customElement, property } from 'lit/decorators.js';
2121
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
2222
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
23+
import { ThemeDetectionMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-detection-mixin.js';
2324

2425
/**
2526
* A Web Component for individual breadcrumb items in a breadcrumb navigation system.
@@ -42,10 +43,11 @@ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
4243
* @name vcf-breadcrumb
4344
* @mixes ElementMixin
4445
* @mixes PolylitMixin
46+
* @mixes ThemeDetectionMixin
4547
* @demo demo/index.html
4648
*/
4749
@customElement("vcf-breadcrumb")
48-
class VcfBreadcrumb extends ElementMixin(PolylitMixin(LitElement)) {
50+
class VcfBreadcrumb extends ThemeDetectionMixin(ElementMixin(PolylitMixin(LitElement))) {
4951

5052
@property({ type: String, reflect: true })
5153
href = '';
@@ -72,7 +74,7 @@ class VcfBreadcrumb extends ElementMixin(PolylitMixin(LitElement)) {
7274
}
7375

7476
static get styles() {
75-
return [css`
77+
return css`
7678
:host {
7779
display: flex;
7880
align-items: center;
@@ -142,7 +144,27 @@ class VcfBreadcrumb extends ElementMixin(PolylitMixin(LitElement)) {
142144
margin: var(--vcf-breadcrumb-separator-margin);
143145
color: inherit;
144146
}
145-
`];
147+
148+
/* Lumo theme */
149+
:host([data-application-theme='lumo']) {
150+
--vcf-breadcrumb-separator-font-family: 'lumo-icons';
151+
--vcf-breadcrumb-separator-symbol: var(--lumo-icons-angle-right);
152+
--vcf-breadcrumb-separator-color: var(--lumo-contrast-40pct);
153+
--vcf-breadcrumb-separator-size: var(--lumo-font-size-s);
154+
--vcf-breadcrumb-separator-margin: 0;
155+
--vcf-breadcrumb-separator-padding: 0 var(--lumo-space-xs);
156+
--vcf-breadcrumb-mobile-back-symbol: var(--lumo-icons-angle-left);
157+
--vcf-breadcrumb-link-focus-ring-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
158+
159+
font-family: var(--lumo-font-family);
160+
font-size: var(--lumo-font-size-m);
161+
}
162+
163+
:host([data-application-theme='lumo']) ::slotted(a[slot="link-slot"]:not(:any-link)) {
164+
/* Lumo global styles use disabled color for anchors without href, force base text color instead */
165+
color: var(--lumo-body-text-color) !important;
166+
}
167+
`;
146168
}
147169

148170
_createAnchor() {

theme/lumo.css

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)