Skip to content
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

docs(card): explain element vs pattern #1188

Merged
merged 27 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f614e17
docs(card): explain element vs pattern
bennypowers Aug 6, 2023
9476a97
docs: missing link
bennypowers Aug 6, 2023
c16cf0f
docs: remove context provider
bennypowers Aug 6, 2023
2b3eec5
docs(card): simplify css
bennypowers Aug 6, 2023
b8f5431
Merge branch 'main' into docs/card-pattern-explanation
bennypowers May 23, 2024
3824798
docs(card): link to patterns from guidelines
bennypowers May 23, 2024
761a991
docs(card): elaborate on patterns
bennypowers May 29, 2024
0e9133e
docs(card): pattern markdown
bennypowers May 29, 2024
1571d07
docs(card): avatar pattern
bennypowers May 29, 2024
d16b27a
docs(card): patterns as sections, not lists
bennypowers May 30, 2024
f4aac26
docs: watch patterns
bennypowers May 30, 2024
2522a41
docs(card): more patterns
bennypowers May 30, 2024
1eb538d
Merge branch 'main' into docs/card-pattern-explanation
bennypowers Jun 5, 2024
e2dea5f
Merge branch 'main' into docs/card-pattern-explanation
zeroedin Jun 21, 2024
8e71528
docs(card-patterns) adding uxdot-pattern component and styling
markcaron Jul 19, 2024
84cd5ee
Update docs/patterns/card/patterns/asset.html
markcaron Jul 21, 2024
363f713
docs(card-patterns): refactor docs
markcaron Jul 22, 2024
2a2c264
docs: use @change instead of mutationobserver setup
zeroedin Jul 22, 2024
ba8bcb8
docs(card-pattern): more content migration and refactoring of pattern…
markcaron Jul 23, 2024
d1cb502
docs(card-pattern): more content migration and pattern examples
markcaron Jul 23, 2024
cb4faa0
docs(card-patterns): moving usage to guidelines tab
markcaron Jul 25, 2024
7ec5537
docs(card-patterns): more card pattern content updates
markcaron Jul 25, 2024
a3070f7
docs(card-pattern): resolving merge conflicts
markcaron Jul 29, 2024
16b5a27
docs(card-patterns): adding explicit card theming demo
markcaron Jul 29, 2024
02186c8
docs(card-patterns): updating rh-cta to new api
markcaron Jul 30, 2024
aff3d8e
docs(card-patterns): changing id-based css to class-based
markcaron Aug 1, 2024
c74498c
Merge branch 'main' into docs/card-pattern-explanation
markcaron Aug 6, 2024
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
2,749 changes: 2,749 additions & 0 deletions docs/_data/playgrounds.json

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions docs/_includes/layouts/pages/pattern.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
layout: layouts/base.njk
importElements:
- rh-cta
- rh-footer
- rh-alert
- rh-subnav
- rh-code-block
---
{% if hasToc %}
<link rel="stylesheet" href="{{ '/assets/javascript/elements/uxdot-toc-lightdom.css' | url }}">
{% endif %}
<link rel="stylesheet" href="{{ '/styles/pages/backpage.css' | url }}">

<script type="module" src="{{ '/assets/javascript/elements/uxdot-feedback.js' | url }}"></script>
<script type="module" src="{{ '/assets/javascript/elements/uxdot-pattern.js' | url }}"></script>
{% if hasToc %}
<script type="module" src="{{ '/assets/javascript/elements/uxdot-toc.js' | url }}"></script>
{% endif %}
{% if tokenSearch %}
<script type="module" src="{{ '/assets/javascript/elements/uxdot-search.js' | url }}"></script>
<script type="module" src="{{ '/assets/javascript/tokens.js' | url }}"></script>
{% endif %}
{% include 'partials/component/masthead.njk' %}
{% include 'partials/component/sidenav.njk' %}

<main id="main">
<article {% if hasToc and (content | toc).length > 0 %}class="has-toc"{% endif %}>

{% include 'partials/component/header.njk' %}
{% if hasToc and (content | toc).length > 0 %}
<aside>
<uxdot-toc summary="On this page">
{{ content | toc | safe }}
</uxdot-toc>
</aside>
{% endif %}

<div class="container">
{{ content | safe }}
</div>

</article>
{% include "partials/component/back-to-top.njk" %}
</main>
{% include 'partials/component/footer.njk' %}
2 changes: 1 addition & 1 deletion docs/_includes/partials/component/feedback.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ <h2>Related elements or patterns</h2>
</ul>
{% else %}
<h2>Other libraries</h2>
<p>To learn more about our other libraries, visit <a href="/get-started/">this page</a>.</p>
<p>To learn more about our other libraries, visit the <a href="/get-started/">getting started page</a>.</p>
{% endif %}
</uxdot-feedback>
164 changes: 164 additions & 0 deletions docs/assets/javascript/elements/uxdot-pattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { LitElement, css, html } from 'lit';
import { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';

import '@rhds/elements/rh-surface/rh-surface.js';
import '@rhds/elements/rh-code-block/rh-code-block.js';
import '@rhds/elements/lib/elements/rh-context-picker/rh-context-picker.js';

class UxdotPattern extends LitElement {
static styles = css`
:host {
display: block;
container-name: host;
container-type: inline-size;
margin-block-end: var(--rh-space-2xl, 32px);
}

#container {
display: grid;
grid-template-columns: 1fr;
grid-template-areas: "controls" "example" "code";
column-gap: var(--rh-space-4xl, 64px);
row-gap: var(--rh-space-2xl, 32px);
padding: var(--rh-space-2xl, 32px);
border: var(--rh-border-width-sm, 1px) solid var(--rh-color-border-subtle-on-light, #c7c7c7);
border-radius: var(--rh-border-radius-default, 3px);
}

#container.dark {
background-color: var(--_context-background-color);
color: var(--_context-text);
border-color: var(--rh-color-border-subtle-on-dark, #707070);
}

#container h3,
#container ::slotted(h2),
#container ::slotted(h3),
#container ::slotted(h4),
#container ::slotted(h5),
#container ::slotted(h6) {
margin-block-start: 0 !important;
margin-block-end: var(--rh-space-lg, 16px) !important;
font-size: var(--rh-font-size-body-text-lg, 1.125rem) !important;
}

#color-picker {
grid-area: controls;
justify-self: flex-end;
display: flex;
align-items: center;
gap: var(--rh-space-lg, 16px);
}

#example {
grid-area: example;
}

#example ::slotted(*) {
display: block;
max-width: 360px;
}

:host([stacked]) #example ::slotted(*) {
max-width: 100%;
}

#code {
grid-area: code;
display: flex;
flex-direction: column;
gap: var(--rh-space-lg, 16px);
}

:host([no-colorpicker]) #container {
grid-template-areas: "example" "code";
}

:host([no-colorpicker]) #color-picker {
display: none !important;
}

@container host (min-width: 992px) {
#container {
grid-template-columns: max-content 1fr;
grid-template-areas: "controls controls"
"example code";
}

:host([no-colorpicker]) #container {
grid-template-areas: "example code";
}

:host([stacked]) #container {
grid-template-columns: 1fr;
grid-template-areas: "controls" "example" "code";
}

:host([stacked][no-colorpicker]) #container {
grid-template-areas: "example" "code";
}
}
`;

static properties = {
colorPalette: { type: String, reflect: true, attribute: 'color-palette' },
target: { type: String, reflect: true },
noColorPicker: { type: Boolean, reflect: true, attribute: 'no-colorpicker' },
stacked: { type: Boolean, reflect: true },
allow: { type: String, reflect: true },
};

#slots;

constructor() {
super();
this.colorPalette = 'lightest';
this.target = 'container';
this.noColorPicker = false;
this.stacked = false;
this.#slots = new SlotController(this, 'html', 'css', 'js');
}

render() {
const hasHtml = this.#slots.hasSlotted('html');
const hasCss = this.#slots.hasSlotted('css');
const hasJs = this.#slots.hasSlotted('js');
const allowed = this.allow ?? `lightest, lighter, light, dark, darker, darkest`;
return html`
<rh-surface id="container" part="container" @change="${this.#onMutation}">
<label id="color-picker">
Color palette
<rh-context-picker target="${this.target}" value="${this.colorPalette}" allow="${allowed}"></rh-context-picker>
</label>
<div id="example">
<slot name="heading"><h3>Example</h3></slot>
<slot></slot>
</div>
<div id="code">
${hasHtml ? html`
<div id="html">
<slot name="html-heading"><h3>HTML</h3></slot>
<slot name="html"></slot>
</div>` : ``}
${hasCss ? html`
<div id="css">
<slot name="css-heading"><h3>CSS</h3></slot>
<slot name="css"></slot>
</div>` : ``}
${hasJs ? html`
<div id="js">
<slot name="js-heading"><h3>JS</h3></slot>
<slot name="js"></slot>
</div>` : ``}
</div>
</rh-surface>
`;
}

#onMutation(changed) {
this.colorPalette = changed.colorPalette;
this.requestUpdate();
}
}

customElements.define('uxdot-pattern', UxdotPattern);
138 changes: 138 additions & 0 deletions docs/patterns/card/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
title: Examples
heading: Card
sidenavTitle: Card
layout: layouts/pages/pattern.njk
hasToc: true
order: 20
tags:
- cardPatterns
subnav:
collection: cardPatterns
order: 3
importElements:
- rh-card
- rh-cta
- rh-surface
- rh-avatar
- rh-accordion
- rh-blockquote
---

<script type="module">
import '@rhds/elements/lib/elements/rh-context-picker/rh-context-picker.js';
</script>

<link rel="stylesheet" href="{{ '/assets/packages/@rhds/elements/elements/rh-table/rh-table-lightdom.css' | url }}">
<link rel="stylesheet" href="{{ '/styles/samp.css' | url }}">

<style>
rh-card {
display: block;
max-width: 360px;
}

[color-palette^="light"] :is(a):link {
color: var(--rh-color-interactive-blue-darker, #0066cc);
}

[color-palette^="light"] :is(a):hover {
color: var(--rh-color-interactive-blue-darkest, #003366);
}

[color-palette^="dark"] :is(a):link {
color: var(--rh-color-interactive-blue-lighter, #92c5f9);
}

[color-palette^="dark"] :is(a):hover {
color: var(--rh-color-interactive-blue-lightest, #b9dafc);
}
</style>


## Asset cards
Use to display that an asset can be downloaded. An icon and label group or
text may be used to describe the asset.

{% include './patterns/asset.html' %}


## Avatars card

Use to highlight a group of people who engage in an event. A label
should be included, but including text is optional.

Use the [`<rh-avatar>`](/elements/avatar/) element to element to present
the list of users.

{% include './patterns/avatars.html' %}


## Fast facts card
Use to display quick facts or short data points under a label. A Secondary
call to action may be used or not.

{% include './patterns/fast-facts.html' %}


## Icon card

Use to add an icon to the basic style above the text. Secondary and Default
calls to action may be used.

{% include './patterns/icon.html' %}

## Image card

Use to add an image to the basic style above the text.
Secondary and Default calls to action may be used.

{% include './patterns/image.html' %}


## List cards
Use to display a short amount of content using various list styles.
Secondary and Default calls to action may be used.


{% include './patterns/list.html' %}


## Logo cards
Use to display a customer logo in a variety of arrangements. A call to
action is required, otherwise use a logo wall.

{% include './patterns/logos.html' %}


## Title bar card

Use to add a small icon and a label group to the header section. A larger icon
or a logo may be used.

Alternative title bar styles can be achieved by selecting [card's `header` CSS
Shadow Part](/elements/card/code/#parts).

{% include './patterns/title-bar.html' %}


## Quote cards

Use to display a short quote with attribution text. Logos, images, and a
Secondary call to action may be used or not.

{% include './patterns/quote.html' %}


<!-- ## Video cards

Use to trigger a video that will play in a [Modal dialog](/elements/dialog).
Different layout configurations may be used.

{% include './patterns/video.html' %} -->


{% include 'partials/component/feedback.html' %}

[element]: /elements/card
[css-props]: /elements/card/code/#css-custom-properties
Loading
Loading