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-1682] Create Global Gap Prop #4067

Merged
merged 38 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a5904f8
Add Gap to globalProps.ts
Lsimmons98 Dec 30, 2024
3ad34a0
Add Gap to globalPropNames.mjs
Lsimmons98 Dec 30, 2024
21de9a9
Add gap to _flex_item.tsx
Lsimmons98 Dec 30, 2024
b81328c
Create _gap.scss
Lsimmons98 Dec 30, 2024
9da0eb4
Create gap_jsx.txt
Lsimmons98 Dec 30, 2024
377ab0c
Create Gap.tsx for Gap Visual Guideline Page
Lsimmons98 Dec 30, 2024
02264c2
Add Gap to Visual Guidelines so that it routes properly from the visu…
Lsimmons98 Dec 30, 2024
ac89662
Add gap to globalPropsValues.ts
Lsimmons98 Dec 30, 2024
60faeb2
Fix global props names list
Lsimmons98 Dec 30, 2024
e7fe325
remove code comment
Lsimmons98 Dec 30, 2024
8a54ca5
fix globalProps.ts
Lsimmons98 Jan 2, 2025
ca39257
GuidelinesNavItems.ts
Lsimmons98 Jan 2, 2025
5785851
Add gap to classnames, modify scss
Lsimmons98 Jan 2, 2025
5652c73
Fix props
Lsimmons98 Jan 2, 2025
b72884e
fix gap function
Lsimmons98 Jan 2, 2025
21cdd5b
fix gap method
Lsimmons98 Jan 2, 2025
88d93fc
remove changes to flex
Lsimmons98 Jan 2, 2025
4af8d4b
Change gap.scss
Lsimmons98 Jan 3, 2025
70729e6
Add gap to flexbox visual guidelines
Lsimmons98 Jan 3, 2025
e98ffb5
Remove gap from visualGuidelines menu
Lsimmons98 Jan 3, 2025
f5c8096
disable gap global prop for flex kit
Lsimmons98 Jan 3, 2025
dec5cdc
remove changes to visual guidelines index
Lsimmons98 Jan 3, 2025
5e2e2b3
remove gap from GuidelinesNavItems
Lsimmons98 Jan 3, 2025
c186e55
Merge branch 'master' into play-1682
Lsimmons98 Jan 3, 2025
0a410d1
Remove flex kit changes
Lsimmons98 Jan 3, 2025
0f84da1
Merge branch 'play-1682' of github.com:powerhome/playbook into play-1682
Lsimmons98 Jan 3, 2025
e634be5
Update _flex.tsx
Lsimmons98 Jan 3, 2025
723a44a
Merge branch 'master' into play-1682
Lsimmons98 Jan 3, 2025
c484ab8
update test to include gap prop classname
Lsimmons98 Jan 6, 2025
9d9848d
Merge branch 'play-1682' of github.com:powerhome/playbook into play-1682
Lsimmons98 Jan 6, 2025
44c243e
Merge branch 'master' into play-1682
Lsimmons98 Jan 6, 2025
c69427d
Rename timeline gap prop to item_gap
Lsimmons98 Jan 6, 2025
9c47982
Merge branch 'play-1682' of github.com:powerhome/playbook into play-1682
Lsimmons98 Jan 6, 2025
e3ca86e
Merge branch 'master' into play-1682
Lsimmons98 Jan 6, 2025
07d8396
Adjust timeline_spec
Lsimmons98 Jan 6, 2025
6bdfc58
Merge branch 'play-1682' of github.com:powerhome/playbook into play-1682
Lsimmons98 Jan 6, 2025
44c5ca4
Update timeline_with_gap for new item_gap prop name
Lsimmons98 Jan 7, 2025
fa7f97d
correct item_gap to itemGap for react
Lsimmons98 Jan 8, 2025
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
Expand Up @@ -78,6 +78,11 @@ const globalPropsValues = [
type: "union",
values: '"wrap" | "nowrap" | "wrapReverse"'
},
{
prop: "gap",
type: "union",
values: '"none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl"'
},
{
prop: "htmlOptions",
type: "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const PROPS = {
flex: ['none', 'initial', 'auto', '1'],
flexGrow: ['0', '1'],
flexShrink: ['0', '1'],
order: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', 'none']
order: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', 'none'],
gap: ['none', 'xxs', 'xs', 'sm', 'md', 'lg', 'xl']
}
const TABLE_HEADERS = ['Props', 'Screen Sizes', 'Values']

Expand Down
1 change: 1 addition & 0 deletions playbook/app/entrypoints/playbook.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@
@import 'utilities/truncate';
@import 'utilities/vertical_align';
@import 'utilities/height';
@import 'utilities/gap';
10 changes: 5 additions & 5 deletions playbook/app/pb_kits/playbook/pb_timeline/_timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type TimelineProps = {
id?: string,
orientation?: string,
showDate?: boolean,
gap?: 'xs' | 'sm' | 'md' | 'lg' | 'none',
item_gap?: 'xs' | 'sm' | 'md' | 'lg' | 'none',
} & GlobalProps

const Timeline = ({
Expand All @@ -32,15 +32,15 @@ const Timeline = ({
id,
orientation = 'horizontal',
showDate = false,
gap = 'none',
item_gap = 'none',
...props
}: TimelineProps): React.ReactElement => {
const ariaProps = buildAriaProps(aria)
const dataProps = buildDataProps(data)
const htmlProps = buildHtmlProps(htmlOptions)
const dateStyle = showDate === true ? '_with_date' : ''
const gapStyle = gap === 'none' ? '' : `gap_${gap}`
const timelineCss = buildCss('pb_timeline_kit', `${orientation}`, dateStyle, gapStyle)
const itemGapStyle = item_gap === 'none' ? '' : `gap_${item_gap}`
const timelineCss = buildCss('pb_timeline_kit', `${orientation}`, dateStyle, itemGapStyle)

return (
<div
Expand All @@ -60,4 +60,4 @@ Timeline.Step = TimelineStep
Timeline.Label = TimelineLabel
Timeline.Detail = TimelineDetail

export default Timeline
export default Timeline
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= pb_rails("flex", props: { justify: "evenly" }) do %>
<%= pb_rails("flex/flex_item") do %>
<%= pb_rails("timeline", props: {orientation: "vertical", gap: "xs"}) do %>
<%= pb_rails("timeline", props: {orientation: "vertical", item_gap: "xs"}) do %>
<%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal"}) do %>
<%= pb_rails("body", props: {
text: "Conversation started",
Expand All @@ -23,7 +23,7 @@
<% end %>

<%= pb_rails("flex/flex_item") do %>
<%= pb_rails("timeline", props: {orientation: "vertical", gap: "sm"}) do %>
<%= pb_rails("timeline", props: {orientation: "vertical", item_gap: "sm"}) do %>
<%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal"}) do %>
<%= pb_rails("body", props: {
text: "Conversation started",
Expand All @@ -46,7 +46,7 @@
<% end %>

<%= pb_rails("flex/flex_item") do %>
<%= pb_rails("timeline", props: {orientation: "vertical", gap: "md"}) do %>
<%= pb_rails("timeline", props: {orientation: "vertical", item_gap: "md"}) do %>
<%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal"}) do %>
<%= pb_rails("body", props: {
text: "Conversation started",
Expand All @@ -69,7 +69,7 @@
<% end %>

<%= pb_rails("flex/flex_item") do %>
<%= pb_rails("timeline", props: {orientation: "vertical", gap: "lg"}) do %>
<%= pb_rails("timeline", props: {orientation: "vertical", item_gap: "lg"}) do %>
<%= pb_rails("timeline/item", props: {icon: "user", icon_color: "royal"}) do %>
<%= pb_rails("body", props: {
text: "Conversation started",
Expand All @@ -91,4 +91,3 @@
<% end %>
<% end %>
<% end %>

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const TimelineWithGap = (props) => (
<Flex justify="evenly">
<FlexItem>
<Timeline
gap="xs"
item_gap="xs"
orientation="vertical"
>
<Timeline.Item
Expand Down Expand Up @@ -51,7 +51,7 @@ const TimelineWithGap = (props) => (
</FlexItem>
<FlexItem>
<Timeline
gap="sm"
item_gap="sm"
orientation="vertical"
>
<Timeline.Item
Expand Down Expand Up @@ -92,7 +92,7 @@ const TimelineWithGap = (props) => (
</FlexItem>
<FlexItem>
<Timeline
gap="md"
item_gap="md"
orientation="vertical"
>
<Timeline.Item
Expand Down Expand Up @@ -134,7 +134,7 @@ const TimelineWithGap = (props) => (
</FlexItem>
<FlexItem>
<Timeline
gap="lg"
item_gap="lg"
orientation="vertical"
>
<Timeline.Item
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Use the optional `gap` prop to render the timeline kit with adjusted spacing between nodes. The `gap` prop will only work when utilized with a vertical timeline. Horizontal timelines will show no difference in spacing.
Use the optional `item_gap` prop to render the timeline kit with adjusted spacing between nodes. The `item_gap` prop will only work when utilized with a vertical timeline. Horizontal timelines will show no difference in spacing.
12 changes: 6 additions & 6 deletions playbook/app/pb_kits/playbook/pb_timeline/timeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ class Timeline < Playbook::KitBase
default: "horizontal"
prop :show_date, type: Playbook::Props::Boolean,
default: false
prop :gap, type: Playbook::Props::Enum,
values: %w[xs sm md lg none],
default: "none"
prop :item_gap, type: Playbook::Props::Enum,
values: %w[xs sm md lg none],
default: "none"

def classname
generate_classname("pb_timeline_kit",
orientation,
date_class,
gap_class)
item_gap_class)
end

private
Expand All @@ -25,8 +25,8 @@ def date_class
show_date ? "with_date" : nil
end

def gap_class
gap == "none" ? nil : "gap_#{gap}"
def item_gap_class
item_gap == "none" ? nil : "gap_#{item_gap}"
end
end
end
Expand Down
29 changes: 29 additions & 0 deletions playbook/app/pb_kits/playbook/utilities/_gap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@import "spacing";

.gap_none {
gap: 0;
}

.gap_xxs {
gap: $space_xxs;
}

.gap_xs {
gap: $space_xs;
}

.gap_sm {
gap: $space_sm;
}

.gap_md {
gap: $space_md;
}

.gap_lg {
gap: $space_lg;
}

.gap_xl {
gap: $space_xl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default [
"overflow",
"order",
"numberSpacing",
"gap",
"maxWidth",
"minWidth",
"width",
Expand Down
27 changes: 18 additions & 9 deletions playbook/app/pb_kits/playbook/utilities/globalProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ type MinWidth = {
minWidth?: string,
}

type Gap = {
gap?: string,
}

type NumberSpacing = {
numberSpacing?: "tabular",
}
Expand Down Expand Up @@ -196,7 +200,7 @@ type MinHeight = {
export type GlobalProps = AlignContent & AlignItems & AlignSelf &
BorderRadius & Cursor & Dark & Display & DisplaySizes & Flex & FlexDirection &
FlexGrow & FlexShrink & FlexWrap & JustifyContent & JustifySelf &
LineHeight & Margin & Width & MinWidth & MaxWidth & NumberSpacing & Order & Overflow & Padding &
LineHeight & Margin & Width & MinWidth & MaxWidth & Gap & NumberSpacing & Order & Overflow & Padding &
Position & Shadow & TextAlign & Truncate & VerticalAlign & ZIndex & { hover?: string } & Top & Right & Bottom & Left & Height & MaxHeight & MinHeight;

const getResponsivePropClasses = (prop: {[key: string]: string}, classPrefix: string) => {
Expand Down Expand Up @@ -372,6 +376,11 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
css += maxWidth ? `max_width_${filterClassName(maxWidth)} ` : ''
return css.trimEnd()
},
gapProps: ({ gap }: Gap) => {
let css = ''
css += gap ? `gap_${gap} ` : ''
return css.trimEnd()
},
minHeightProps: ({ minHeight }: MinHeight) => {
const heightValues = ["auto", "xs", "sm", "md", "lg", "xl", "xxl", "xxxl"]
if (heightValues.includes(minHeight)) {
Expand Down Expand Up @@ -530,15 +539,15 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
},


topProps: ({top}) => getPositioningPropsClasses('top', top),
topProps: ({top}) => getPositioningPropsClasses('top', top),

rightProps: ({right}) => getPositioningPropsClasses('right', right),

rightProps: ({right}) => getPositioningPropsClasses('right', right),
bottomProps:({bottom}) => getPositioningPropsClasses('bottom', bottom),

bottomProps:({bottom}) => getPositioningPropsClasses('bottom', bottom),

leftProps: ({left}) => getPositioningPropsClasses('left', left),


textAlignProps: ({ textAlign }: TextAlign) => {
if (typeof textAlign === 'object') {
return getResponsivePropClasses(textAlign, 'text_align')
Expand All @@ -558,15 +567,15 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =

const PROP_INLINE_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => {[key: string]: any}} = {
heightProps: ({ height }: Height) => {
return height ? { height } : {};
return height ? { height } : {};
},

maxHeightProps: ({ maxHeight }: MaxHeight) => {
return maxHeight ? { maxHeight } : {};
},

minHeightProps: ({ minHeight }: MinHeight) => {
return minHeight ? { minHeight } : {};
return minHeight ? { minHeight } : {};
},
}

Expand Down
1 change: 1 addition & 0 deletions playbook/lib/playbook/classnames.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def generate_classname(*name_parts, separator: "_")
width_props,
min_width_props,
max_width_props,
gap_props,
z_index_props,
number_spacing_props,
shadow_props,
Expand Down
21 changes: 21 additions & 0 deletions playbook/lib/playbook/spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module Playbook
module Spacing
def self.included(base)
base.prop :gap
base.prop :margin
base.prop :margin_bottom
base.prop :margin_left
Expand Down Expand Up @@ -52,6 +53,16 @@ def width_values
%w[0% xs sm md lg xl xxl 0 none 100%]
end

def gap_values
%w[none xxs xs sm md lg xl]
end

def gap_options
{
gap: "gap",
}
end

def spacing_options
{
margin: "m",
Expand Down Expand Up @@ -146,5 +157,15 @@ def width_props
"width_#{filter_classname(width_value)}" if width_values.include? width_value
end.compact.join(" ")
end

def gap_props
selected_gap_props = gap_options.keys.select { |sk| try(sk) }
return nil unless selected_gap_props.present?

selected_gap_props.map do |k|
gap_value = send(k)
"gap_#{gap_value}" if gap_values.include? gap_value
end.compact.join(" ")
end
end
end
Loading