USWDS-Proposals - Pre-alpha: Card web component #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Landscape analysis
Card code samples from the landscape analysis (Google docs 🔒)
Proposed component structure
Critical content
A card is a container for whatever content the user decides to pass into it. Some examples of elements that we may expect users to pass in based on our current card use cases may include:
imgalth1-6pahrefLight DOM
Sample default implementation:
Shadow DOM
Provide a code sample of how the component will be built in the shadow DOM. Provide a default example and a complex example (when applicable).
Variants
In a table, list the current and proposed variants for the component.
Current variants
header-firstinsetexdentlayoutProposed additional variants
N/A
Props
Current variants
header-firstusa-cardelement, the header will display before card mediabooleaninsetusa-cardelement, each slotted section of the card will take the inset styles.Alternatively,
insetcan be added to individual slots to only add inset styles to that slotbooleanexdentusa-cardelement, each slotted section of the card will take the exdent styles.Alternatively,
exdentcan be added to individual slots to only add exdent styles to that slotbooleanlayoutusa-cardelement, users can choose to display flag or flag-alt layouts.Flag will display with media on the left.
Flag-alt will display with media on the right.
flag,flag-altProposed additional variants
N/A
Slots
genericAny content not passed to a slot will appear in this generic slot.
card-mediaimg.usa-card__mediamarkupcard-headingdivcard-footerdivCSS Parts
bodyslotCSS Variables
Current settings
$theme-card-border-color--usa-theme-card-border-color$theme-card-border-radius--usa-theme-card-border-radius$theme-card-border-width--usa-theme-card-border-width$theme-card-gap--usa-theme-card-gap$theme-card-flag-min-width--usa-theme-card-flag-min-width$theme-card-flag-image-width--usa-theme-card-flag-image-width$theme-card-font-family--usa-theme-card-font-family$theme-card-header-typeset--usa-theme-card-header-font-family$theme-card-margin-bottom--usa-theme-card-margin-bottom$theme-card-padding-perimeter--usa-theme-card-padding-perimeter$theme-card-padding-y--usa-theme-card-padding-y:Proposed additional setting
N/A
Translatable content
All content in the card element will be passed directly by the suer into slots. This should make it easy to be flexible and take provided translations without an issue. Users could potentially also set up their cards to take in data via JSON, so providing translated JSON data would allow for easy content switches.