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

Allow Responsive Display Global Props #1846

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5141d75
Added conditional to displayProps
diontheroulde Apr 12, 2022
52d0e84
Added breakpoint query
diontheroulde Apr 13, 2022
86e4968
Removed commented out code
diontheroulde Apr 13, 2022
d369c00
Trying to display gloabl props
diontheroulde Apr 14, 2022
3cccb64
Display global props
thestephenmarshall Apr 14, 2022
a2d1baf
Display breakpoints on rails
diontheroulde Apr 20, 2022
9cd88e9
Merge branch 'master' of github.com:powerhome/playbook into PLAY-33-G…
diontheroulde Apr 20, 2022
ee8d7e8
Merge branch 'master' of github.com:powerhome/playbook into PLAY-33-G…
diontheroulde Apr 21, 2022
a023541
Working on multiple screen sizes
diontheroulde Apr 21, 2022
5d6daac
Display global props at multiple screen sizes
diontheroulde Apr 25, 2022
ad84e31
Added Props pill back for display
diontheroulde Apr 27, 2022
045d377
Separate base types
thestephenmarshall Apr 28, 2022
1832dcd
Fix display.rb css output
thestephenmarshall Apr 28, 2022
bf64dd8
Merge branch 'master' of github.com:powerhome/playbook into PLAY-33-G…
diontheroulde Apr 28, 2022
43f25fb
Diplay working for both rails and react
diontheroulde Apr 28, 2022
1c66bb5
Global props work fro single display value
diontheroulde Apr 28, 2022
f8656fb
Edited visual guidelines styling
diontheroulde Apr 29, 2022
3d25b08
Fixed syntax for display.ts
diontheroulde Apr 29, 2022
9f59d1a
Switched display.ts syntax back
diontheroulde Apr 29, 2022
359811f
Fixed syntax error this time
diontheroulde Apr 29, 2022
90edcdc
Merge remote-tracking branch 'origin/master' into PLAY-33-Global-resp…
thestephenmarshall May 2, 2022
e477fac
Fix types and SCSS classes
thestephenmarshall May 2, 2022
8b1037c
Add breakpoints grid to screen sizes
thestephenmarshall May 4, 2022
8f56759
Don't make changes to unassociated files
thestephenmarshall May 4, 2022
373783c
All files should have one empty line at the end per code style rules
thestephenmarshall May 4, 2022
56eeda4
Add colors type
thestephenmarshall May 11, 2022
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<Button display="flex">
Button Text
<Button/>
<Card display="flex">
Card content
<Card/>

<Card
display={
xs: "hidden",
sm: "flex",
md: "inline",
lg: "inline_block",
xl: "block"
}
>
Card content
<Card/>
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
<%= pb_rails("title", props: { text: "Display", size: 1, margin_top: "xl", padding_top: "xl" }) %>
<%= pb_rails("body", props: { tag: "p", margin_top: "xs", margin_bottom: "lg" }) do %>
<% end %>
<%= pb_rails("title", props: { text: "Global Props", tag: "h3", size: 4, margin_bottom: "xs" }) %>
<%= pb_rails("body", props: { text: "Available in every kit. These are added globally as they are most flexible when developing.", margin_bottom: "sm" }) %>
<%= pb_rails("title", props: { text: "Display", size: 1, margin_bottom: "sm", margin_top: "xl", padding_top: "xl" }) %>
<%= pb_rails("title", props: { text: "Global Props", tag: "h3", size: 4, margin_bottom: "xs" }) %>
<%= pb_rails("body", props: { text: "Available in every kit. These are added globally as they are most flexible when developing.", margin_bottom: "sm", margin_top: "xs" }) %>
<%= pb_rails("card", props: { shadow: "deep", margin_bottom: "sm", padding: "none" }) do %>
<%= pb_rails("flex", props: { vertical: "stretch", padding_x: "md", padding_top: "md", padding_bottom: "md" }) do %>
<%= pb_rails("flex/flex_item", props: { flex: "1" }) do %>
<%= pb_rails("caption", props: { text: "Props", margin_bottom: "sm" }) %>
<%= pb_rails("pill", props: { text: "display", variant: "neutral" }) %>
<% end %>
<%= pb_rails("section_separator", props: { orientation: "vertical", margin_x: "sm" }) %>
<%= pb_rails("flex/flex_item", props: { flex: "1" }) do %>
<%= pb_rails("caption", props: { text: "Values", margin_bottom: "sm" }) %>
<%= pb_rails("pill", props: { text: "block", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "inline_block", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "inline", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "flex", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "inline_flex", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "hidden", variant: "warning" }) %>
<% end %>
<%= pb_rails("flex", props: { vertical: "stretch", padding_x: "md", padding_top: "md", padding_bottom: "md" }) do %>
<%= pb_rails("flex/flex_item", props: { flex: "1"}) do %>
<%= pb_rails("caption", props: { text: "Props", margin_bottom: "sm" })%>
<%= pb_rails("pill", props: { text: "Display", variant: "neutral"})%>
<% end %>
<%= pb_rails("section_separator", props: { orientation: "vertical", margin_x: "sm" }) %>
<%= pb_rails("flex/flex_item", props: { flex: "1" }) do %>
<%= pb_rails("caption", props: { text: " Screen Sizes", margin_bottom: "sm" }) %>
<%= pb_rails("pill", props: { text: "xs", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "sm", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "md", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "lg", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "xl", variant: "warning" }) %>
<% end %>
<%= pb_rails("background", props: { id: "code-wrapper", classname: "border-bottom", background_color: "dark", padding: "none" }) do %>
<%= pb_rails("caption", props: { text: "EXAMPLE IN USE", padding_top: "lg", margin_x: "xl", classname: "dark" }) %>
<div class="pb--codeCopy">
<pre class="highlight pt_sm" style="margin: 0px"><%= raw rouge(@display_in_use_code_example, "react") %></pre>
</div>
<%= pb_rails("section_separator", props: { orientation: "vertical", margin_x: "sm" }) %>
<%= pb_rails("flex/flex_item", props: { flex: "1" }) do %>
<%= pb_rails("caption", props: { text: "Values", margin_bottom: "sm" }) %>
<%= pb_rails("pill", props: { text: "inline", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "flex", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "inline_block", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "block", variant: "warning" }) %>
<%= pb_rails("pill", props: { text: "hidden", variant: "warning" }) %>
<% end %>
<% end %>
<% end %>
<%= pb_rails("background", props: { id: "code-wrapper", classname: "border-bottom", background_color: "dark", padding: "none" }) do %>
<%= pb_rails("caption", props: { text: "EXAMPLE IN USE", padding_top: "lg", margin_x: "xl", classname: "dark" }) %>
<div class="pb--codeCopy">
<pre class="highlight pt_sm" style="margin: 0px"><%= raw rouge(@display_in_use_code_example, "react") %></pre>
</div>
<% end %>
<% end %>
<%= render "pages/visual_guidelines_partials/display_breakpoints"%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<%= pb_rails("title", props: { text: "Utility Classes", tag: "h3", size: 4, margin_bottom: "xs", padding_top: "xs" }) %>
<%= pb_rails("body", props: { text: "Just want the raw classes? We got you. All of our global props are simple CSS utilities available through classes.", margin_bottom: "sm" }) %>
<%= pb_rails("caption", props: { text: "Visual Guide", margin_bottom: "sm" }) %>
<%= pb_rails("card", props: {
margin_bottom: "none",
padding: "none",
shadow: "deep"
}) do %>
<%= pb_rails("table", props: { size: "sm" }) do %>
<thead>
<tr>
<th>Screen Size</th>
<th>@media screen</th>
<th>Class</th>
<th>Properties</th>
</tr>
</thead>
<tbody>
<tr>
<td>xs</td>
<td>@media screen and (max-width: 575px)</td>
<td>.display_xs_hidden</td>
<td>display: hidden !important</td>
</tr>
<tr>
<td>sm</td>
<td>@media screen and (max-width: 576px)</td>
<td>.display_sm_block</td>
<td>display: block !important</td>
</tr>
<tr>
<td>md</td>
<td>@media screen and (max-width: 768px)</td>
<td>.display_md_inline_block</td>
<td>display: inline-block !important</td>
</tr>
<tr>
<td>lg</td>
<td>@media screen and (max-width: 992px)</td>
<td>.display_lg_inline</td>
<td>display: inline !important</td>
</tr>
<tr>
<td>xl</td>
<td>@media screen and (max-width: 1200px)</td>
<td>.display_xl_flex</td>
<td>display: flex !important</td>
</tr>
</tbody>
<% end %>
<% end %>
6 changes: 3 additions & 3 deletions playbook/app/pb_kits/playbook/pb_avatar/_avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react'
import classnames from 'classnames'

import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'
import { globalProps, GlobalProps } from '../utilities/globalProps'

import Image from '../pb_image/_image'
import OnlineStatus from '../pb_online_status/_online_status'
Expand All @@ -18,14 +18,14 @@ type AvatarProps = {
name: string,
size?: "md" | "lg" | "sm" | "xl" | "xs" | "xxs",
status: "away" | "offline" | "online",
}
} & GlobalProps

const firstTwoInitials = (name: string) =>
name.split(/\s/).map((name) => name[0])
.join('')
.substring(0, 2)

const Avatar = (props: AvatarProps) => {
const Avatar = (props: AvatarProps): React.ReactElement => {
const {
aria = {},
className,
Expand Down
16 changes: 8 additions & 8 deletions playbook/app/pb_kits/playbook/pb_body/_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import classnames from 'classnames'

import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
import { globalProps } from '../utilities/globalProps'
import { globalProps, GlobalProps } from '../utilities/globalProps'

import Highlight from '../pb_highlight/_highlight'

Expand All @@ -20,7 +20,7 @@ type BodyProps = {
tag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'div',
text?: string,
variant: null | 'link',
}
} & GlobalProps

const Body = (props: BodyProps): React.ReactElement => {
const {
Expand Down Expand Up @@ -56,12 +56,12 @@ const Body = (props: BodyProps): React.ReactElement => {
id={id}
>
{ highlighting && (
<Highlight
highlightedText={highlightedText}
text={text}
>
{children}
</Highlight>
<Highlight
highlightedText={highlightedText}
text={text}
>
{children}
</Highlight>
) }
{ !highlighting && (
text || children
Expand Down
1 change: 1 addition & 0 deletions playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "../tokens/colors";
@import "../tokens/transition";
@import "../tokens/animation-curves";
@import "../tokens/display";

$pb_card_border_width: 1px;
$pb_card_border_radius: $border_rad_heavier;
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_image/_image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ImageType = {
url?: string,
} & GlobalProps

const Image = (props: ImageType) => {
const Image = (props: ImageType): React.ReactElement => {
const {
alt = '',
aria = {},
Expand Down
13 changes: 13 additions & 0 deletions playbook/app/pb_kits/playbook/tokens/_display.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$display_inline: inline;
$display_block: block;
$display_inline_block: inline-block;
$display_flex: flex;
$display_none: none;
$display_inline_flex: inline-flex;
$displays: (
display_none: $display_none,
display_flex: $display_flex,
display_inline: $display_inline,
display_inline_block: $display_inline_block,
display_block: $display_block
);
36 changes: 36 additions & 0 deletions playbook/app/pb_kits/playbook/tokens/_screen_sizes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@ $breakpoints: (
xl: $screen-xl-min
);

$breakpoints_grid: (
xs: (
max: $screen-xs-min
),
sm: (
min: $screen-sm-min,
max: $screen-md-max
),
md: (
min: $screen-md-min,
max: $screen-lg-max
),
lg: (
min: $screen-lg-min,
max: $screen-xl-max
),
xl: (
min: $screen-xl-min,
)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relates to the break_on mixin


@function breakpoint($breakpoint_name) {
@return map-get($breakpoints, $breakpoint_name);
Expand All @@ -28,3 +48,19 @@ $breakpoints: (
@content;
}
}

@mixin break_on($min: null, $max: null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mixin will create a breakpoint grid with min and max sizes. This is the only way we could get the CSS declarations to apply.

@if not $max {
@media screen and (min-width: $min) {
@content;
}
} @else if not $min {
@media screen and (max-width: $max) {
@content;
}
} @else {
@media screen and (min-width: $min) and (max-width: $max) {
@content;
}
}
}
8 changes: 8 additions & 0 deletions playbook/app/pb_kits/playbook/types/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Simple base types
import { SyntheticEvent } from "react"

export type Binary = 0 | 1
export type Callback<T, K> = (arg: T) => K
export type EmptyObject = Record<string, unknown>
export type InputCallback<T> = Callback<SyntheticEvent<T>, void>
export type Noop = () => void
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import { SyntheticEvent } from "react"

export type Callback<T, K> = (arg: T) => K
export type InputCallback<T> = Callback<SyntheticEvent<T>, void>

export type BackgroundColors = "white" | "dark" | "light"
export type CategoryColors = "category_1" | "category_2" | "category_3" | "category_4" | "category_5" | "category_6" | "category_7" | "category_8" | "category_9" | "category_10" | "category_11" | "category_12" | "category_13" | "category_14" | "category_15" | "category_16" | "category_17" | "category_18" | "category_19" | "category_20" | "category_21"
export type ProductColors = "windows" | "siding" | "doors" | "solar" | "roofing" | "gutters" | "insulation"
9 changes: 9 additions & 0 deletions playbook/app/pb_kits/playbook/types/display.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export type DisplayType = "none" | "flex" | "inline_flex" | "inline" | "inline_block" | "block"

export type Display = {
display?: DisplayType,
} | DisplaySizes

export type DisplaySizes = {[key: string]: DisplayType | any}

export type None = "none"
4 changes: 4 additions & 0 deletions playbook/app/pb_kits/playbook/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './base'
export * from './colors'
export * from './display'
export * from './sizes'
1 change: 1 addition & 0 deletions playbook/app/pb_kits/playbook/types/sizes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Sizes = "xxs" | "xs" | "sm" | "md" | "lg" | "xl"
28 changes: 26 additions & 2 deletions playbook/app/pb_kits/playbook/utilities/_display.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "../tokens/display";

.display_block {
display: block;
}
Expand All @@ -18,6 +20,28 @@
display: inline-flex;
}

.display_hidden {
.display_none {
display: none;
}
}

$display_values: (
none: $display_none,
flex: $display_flex,
inline: $display_inline,
inline_block: $display_inline_block,
inline_flex: $display_inline_flex,
block: $display_block
);

// using a grid here
@each $size, $size_value in $breakpoints_grid {
@each $display, $display_value in $display_values {
$min_size: map-get($size_value, "min");
$max_size: map-get($size_value, "max");
.display_#{$size}_#{$display} {
@include break_on($min_size, $max_size) {
display: #{$display_value} !important;
}
}
}
}
Loading