-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract form-layout styles into reusable CSS literal (#8340)
- Loading branch information
1 parent
56c8c24
commit ac91ad5
Showing
4 changed files
with
112 additions
and
88 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
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 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2018 - 2024 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 formLayoutStyles: CSSResult; | ||
|
||
export const formItemStyles: CSSResult; |
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,94 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2018 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
|
||
export const formLayoutStyles = css` | ||
:host { | ||
display: block; | ||
max-width: 100%; | ||
animation: 1ms vaadin-form-layout-appear; | ||
/* CSS API for host */ | ||
--vaadin-form-item-label-width: 8em; | ||
--vaadin-form-item-label-spacing: 1em; | ||
--vaadin-form-item-row-spacing: 1em; | ||
--vaadin-form-layout-column-spacing: 2em; /* (default) */ | ||
align-self: stretch; | ||
} | ||
@keyframes vaadin-form-layout-appear { | ||
to { | ||
opacity: 1 !important; /* stylelint-disable-line keyframe-declaration-no-important */ | ||
} | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
#layout { | ||
display: flex; | ||
align-items: baseline; /* default \`stretch\` is not appropriate */ | ||
flex-wrap: wrap; /* the items should wrap */ | ||
} | ||
#layout ::slotted(*) { | ||
/* Items should neither grow nor shrink. */ | ||
flex-grow: 0; | ||
flex-shrink: 0; | ||
/* Margins make spacing between the columns */ | ||
margin-left: calc(0.5 * var(--vaadin-form-layout-column-spacing)); | ||
margin-right: calc(0.5 * var(--vaadin-form-layout-column-spacing)); | ||
} | ||
#layout ::slotted(br) { | ||
display: none; | ||
} | ||
`; | ||
|
||
export const formItemStyles = css` | ||
:host { | ||
display: inline-flex; | ||
flex-direction: row; | ||
align-items: baseline; | ||
margin: calc(0.5 * var(--vaadin-form-item-row-spacing, 1em)) 0; | ||
} | ||
:host([label-position='top']) { | ||
flex-direction: column; | ||
align-items: stretch; | ||
} | ||
:host([hidden]) { | ||
display: none !important; | ||
} | ||
#label { | ||
width: var(--vaadin-form-item-label-width, 8em); | ||
flex: 0 0 auto; | ||
} | ||
:host([label-position='top']) #label { | ||
width: auto; | ||
} | ||
#spacing { | ||
width: var(--vaadin-form-item-label-spacing, 1em); | ||
flex: 0 0 auto; | ||
} | ||
#content { | ||
flex: 1 1 auto; | ||
} | ||
#content ::slotted(.full-width) { | ||
box-sizing: border-box; | ||
width: 100%; | ||
min-width: 0; | ||
} | ||
`; |
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