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

[PLAY-1629] Add Status Color to Card Header #4044

Merged
merged 3 commits into from
Dec 26, 2024
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
14 changes: 7 additions & 7 deletions playbook/app/pb_kits/playbook/pb_card/_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames'

import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
import { GlobalProps, globalProps, globalInlineProps } from '../utilities/globalProps'
import type { ProductColors, CategoryColors, BackgroundColors } from '../types/colors'
import type { ProductColors, CategoryColors, BackgroundColors, StatusColors } from '../types/colors'

import Icon from '../pb_icon/_icon'
import Flex from '../pb_flex/_flex'
Expand Down Expand Up @@ -36,7 +36,7 @@ type CardPropTypes = {
} & GlobalProps

type CardHeaderProps = {
headerColor?: BackgroundColors | ProductColors | CategoryColors | "none",
headerColor?: BackgroundColors | ProductColors | CategoryColors | StatusColors | "none",
headerColorStriped?: boolean,
children: React.ReactChild[] | React.ReactChild,
className?: string,
Expand Down Expand Up @@ -127,27 +127,27 @@ const Card = (props: CardPropTypes): React.ReactElement => {

const tagOptions = ['div', 'section', 'footer', 'header', 'article', 'aside', 'main', 'nav']
const Tag = tagOptions.includes(tag) ? tag : 'div'

return (
<>
{
draggableItem ? (
<Draggable.Item dragId={dragId}
<Draggable.Item dragId={dragId}
key={dragId}
>
<Tag
{...ariaProps}
{...dataProps}
className={classnames(cardCss, globalProps(props), className)}
{...restHtmlProps}
style={mergedStyles}
style={mergedStyles}
>
{subComponentTags('Header')}
{
dragHandle ? (
<Flex>
<span className="card_draggable_handle">
<Icon
<Icon
icon="grip-dots-vertical"
paddingRight="xs"
verticalAlign="middle"
Expand All @@ -169,7 +169,7 @@ const Card = (props: CardPropTypes): React.ReactElement => {
{...dataProps}
className={classnames(cardCss, globalProps(props), className)}
{...restHtmlProps}
style={mergedStyles}
style={mergedStyles}
>
{subComponentTags('Header')}
{nonHeaderChildren}
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
Tomm1128 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $additional_colors: (
"neutral_subtle": $neutral_subtle,
);
$background_colors: map-merge($product_colors, $additional_colors);
$pb_card_header_colors: map-merge(map-merge($product_colors, $additional_colors), $category_colors);
$pb_card_header_colors: map-merge(map-merge(map-merge($product_colors, $additional_colors), $category_colors), $status_colors);

@mixin pb_card_selected($border_color: $primary) {
border-color: $border_color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,24 @@
<%= pb_rails("card/card_body", props: { padding: "md", }) do %>
Body
<% end %>
<% end %>
<% end %>

<%= pb_rails("title", props: { text: "Status Colors", tag: "h4", size: 4, margin_bottom: "sm" }) %>

<%= pb_rails("card", props: { padding: "none", header: true, margin_bottom: "sm"}) do %>
<%= pb_rails("card/card_header", props: { padding: "sm", header_color: "success" }) do %>
<%= pb_rails("body", props: { text: "Success", dark: true }) %>
<% end %>
<%= pb_rails("card/card_body", props: { padding: "md" }) do %>
Body
<% end %>
<% end %>

<%= pb_rails("card", props: { padding: "none", header: true, margin_bottom: "sm"}) do %>
<%= pb_rails("card/card_header", props: { padding: "sm", header_color: "error" }) do %>
<%= pb_rails("body", props: { text: "Error", dark: true }) %>
<% end %>
<%= pb_rails("card/card_body", props: { padding: "md" }) do %>
Body
<% end %>
<% end %>
50 changes: 50 additions & 0 deletions playbook/app/pb_kits/playbook/pb_card/docs/_card_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,56 @@ const CardHeader = (props) => {
/>
</Card.Body>
</Card>

<Title
{...props}
marginBottom='sm'
size={4}
tag="h4"
text="Status Colors"
/>

<Card
{...props}
marginBottom='sm'
padding="none"
>
<Card.Header
headerColor="success"
>
<Body
dark
text="Success"
/>
</Card.Header>
<Card.Body>
<Body
{...props}
text="Body"
/>
</Card.Body>
</Card>

<Card
{...props}
marginBottom='sm'
padding="none"
>
<Card.Header
headerColor="error"
>
<Body
dark
text="Error"
/>
</Card.Header>
<Card.Body>
<Body
{...props}
text="Body"
/>
</Card.Body>
</Card>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Card headers pass category, product, and background colors only. List of all category, product, and background colors can be viewed <a href="https://playbook.powerapp.cloud/visual_guidelines/colors" target="_blank">here</a>.
Card headers pass category, product, status and background colors only. List of all category, product, status and background colors can be viewed <a href="https://playbook.powerapp.cloud/visual_guidelines/colors" target="_blank">here</a>.
Loading