Skip to content

refactor: extract field-highlighter core CSS to styles folder #9444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright (c) 2021 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import type { CSSResult } from 'lit';

export const fieldOutlineStyles: CSSResult;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright (c) 2021 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { css } from 'lit';

export const fieldOutlineStyles = css`
:host {
display: block;
box-sizing: border-box;
position: absolute;
inset: 0;
width: 100%;
height: 100%;
pointer-events: none;
user-select: none;
opacity: 0;
--_active-user-color: transparent;
}

:host([has-active-user]) {
opacity: 1;
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @license
* Copyright (c) 2021 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import type { CSSResult } from 'lit';

export const userTagStyles: CSSResult;
41 changes: 41 additions & 0 deletions packages/field-highlighter/src/styles/vaadin-user-tag-styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @license
* Copyright (c) 2021 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { css } from 'lit';

export const userTagStyles = css`
:host {
display: block;
box-sizing: border-box;
margin: 0 0 var(--vaadin-user-tag-offset);
opacity: 0;
height: 1.3rem;
transition: opacity 0.2s ease-in-out;
background-color: var(--vaadin-user-tag-color);
color: #fff;
cursor: default;
-webkit-user-select: none;
user-select: none;
--vaadin-user-tag-offset: 4px;
}

:host(.show) {
opacity: 1;
}

:host(:last-of-type) {
margin-bottom: 0;
}

[part='name'] {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
box-sizing: border-box;
padding: 2px 4px;
height: 1.3rem;
font-size: 13px;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
*/
import type { CSSResult } from 'lit';

export const fieldOutlineStyles: CSSResult;

export const userTagStyles: CSSResult;

export const userTagsOverlayStyles: CSSResult;
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @license
* Copyright (c) 2021 - 2025 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { css } from 'lit';
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';

const userTagsOverlay = css`
:host {
background: transparent;
box-shadow: none;
}

:scope [part='overlay'] {
box-shadow: none;
background: transparent;
position: relative;
left: -4px;
padding: 4px;
outline: none;
overflow: visible;
}

::slotted([part='tags']) {
display: flex;
flex-direction: column;
align-items: flex-start;
}

:host([dir='rtl']) [part='overlay'] {
left: auto;
right: -4px;
}

:scope [part='content'] {
padding: 0;
}

:host([opening]),
:host([closing]) {
animation: 0.14s user-tags-overlay-dummy-animation;
}

@keyframes user-tags-overlay-dummy-animation {
0% {
opacity: 1;
}

100% {
opacity: 1;
}
}
`;

export const userTagsOverlayStyles = [overlayStyles, userTagsOverlay];
107 changes: 0 additions & 107 deletions packages/field-highlighter/src/vaadin-field-highlighter-styles.js

This file was deleted.

10 changes: 6 additions & 4 deletions packages/field-highlighter/src/vaadin-field-outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import { html, LitElement } from 'lit';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { fieldOutlineStyles } from './vaadin-field-highlighter-styles.js';

registerStyles('vaadin-field-outline', fieldOutlineStyles, { moduleId: 'vaadin-field-outline-styles' });
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { fieldOutlineStyles } from './styles/vaadin-field-outline-styles.js';

/**
* An element used internally by `<vaadin-field-highlighter>`. Not intended to be used separately.
Expand All @@ -25,6 +23,10 @@ export class FieldOutline extends ThemableMixin(DirMixin(PolylitMixin(LitElement
return 'vaadin-field-outline';
}

static get styles() {
return fieldOutlineStyles;
}

static get properties() {
return {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/field-highlighter/src/vaadin-user-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { userTagStyles } from './vaadin-field-highlighter-styles.js';
import { userTagStyles } from './styles/vaadin-user-tag-styles.js';

/**
* An element used internally by `<vaadin-field-highlighter>`. Not intended to be used separately.
Expand Down
5 changes: 2 additions & 3 deletions packages/field-highlighter/src/vaadin-user-tags-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
import { userTagsOverlayStyles } from './vaadin-field-highlighter-styles.js';
import { userTagsOverlayStyles } from './styles/vaadin-user-tags-overlay-styles.js';

/**
* An element used internally by `<vaadin-field-highlighter>`. Not intended to be used separately.
Expand All @@ -30,7 +29,7 @@ class UserTagsOverlay extends PositionMixin(OverlayMixin(DirMixin(ThemableMixin(
}

static get styles() {
return [overlayStyles, userTagsOverlayStyles];
return userTagsOverlayStyles;
}

/** @protected */
Expand Down