Skip to content

Commit

Permalink
[PLAY-1629] Add Status Color to Card Header (#4044)
Browse files Browse the repository at this point in the history
**What does this PR do?** A clear and concise description with your
runway ticket url.
Makes it so the header in the card kit can accept status colors for the
background color.

[PLAY-1629](https://runway.powerhrg.com/backlog_items/PLAY-1629)

**Screenshots:** Screenshots to visualize your addition/change

<img width="1290" alt="Screenshot 2024-12-20 at 9 15 41 AM"
src="https://github.com/user-attachments/assets/f66d9ef8-23f4-49cd-b20e-a2a5eb954b96"
/>

**How to test?** Steps to confirm the desired behavior:
1. Go to card kit page
2. Scroll down to card header section
3. See new status color example


#### Checklist:
- [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new
kit`, `deprecated`, or `breaking`. See [Changelog &
Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels)
for details.
- [x] **DEPLOY** I have added the `milano` label to show I'm ready for a
review.
- [ ] **TESTS** I have added test coverage to my code.
  • Loading branch information
Tomm1128 authored Dec 26, 2024
1 parent 12f1d15 commit 13730c1
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 10 deletions.
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
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
22 changes: 21 additions & 1 deletion playbook/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb
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
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_card/docs/_card_header.md
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>.

0 comments on commit 13730c1

Please sign in to comment.