diff --git a/playbook-website/app/javascript/components/AvailableProps/globalPropsValues.ts b/playbook-website/app/javascript/components/AvailableProps/globalPropsValues.ts
index 92a30ed8b8..1b9ecc235e 100644
--- a/playbook-website/app/javascript/components/AvailableProps/globalPropsValues.ts
+++ b/playbook-website/app/javascript/components/AvailableProps/globalPropsValues.ts
@@ -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",
diff --git a/playbook-website/app/javascript/components/VisualGuidelines/Examples/FlexBox.tsx b/playbook-website/app/javascript/components/VisualGuidelines/Examples/FlexBox.tsx
index 92822add9e..c466c42ccc 100644
--- a/playbook-website/app/javascript/components/VisualGuidelines/Examples/FlexBox.tsx
+++ b/playbook-website/app/javascript/components/VisualGuidelines/Examples/FlexBox.tsx
@@ -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']
diff --git a/playbook/app/entrypoints/playbook.scss b/playbook/app/entrypoints/playbook.scss
index ddf84bdb47..8fc632cec7 100755
--- a/playbook/app/entrypoints/playbook.scss
+++ b/playbook/app/entrypoints/playbook.scss
@@ -128,3 +128,4 @@
@import 'utilities/truncate';
@import 'utilities/vertical_align';
@import 'utilities/height';
+@import 'utilities/gap';
diff --git a/playbook/app/pb_kits/playbook/pb_timeline/_timeline.tsx b/playbook/app/pb_kits/playbook/pb_timeline/_timeline.tsx
index 58595e700d..c865c14f16 100644
--- a/playbook/app/pb_kits/playbook/pb_timeline/_timeline.tsx
+++ b/playbook/app/pb_kits/playbook/pb_timeline/_timeline.tsx
@@ -20,7 +20,7 @@ type TimelineProps = {
id?: string,
orientation?: string,
showDate?: boolean,
- gap?: 'xs' | 'sm' | 'md' | 'lg' | 'none',
+ itemGap?: 'xs' | 'sm' | 'md' | 'lg' | 'none',
} & GlobalProps
const Timeline = ({
@@ -32,15 +32,15 @@ const Timeline = ({
id,
orientation = 'horizontal',
showDate = false,
- gap = 'none',
+ itemGap = '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 = itemGap === 'none' ? '' : `gap_${itemGap}`
+ const timelineCss = buildCss('pb_timeline_kit', `${orientation}`, dateStyle, itemGapStyle)
return (
<%= 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",
@@ -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",
@@ -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",
@@ -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",
@@ -91,4 +91,3 @@
<% end %>
<% end %>
<% end %>
-
diff --git a/playbook/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx b/playbook/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx
index e6a9486f04..760321ca31 100644
--- a/playbook/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx
+++ b/playbook/app/pb_kits/playbook/pb_timeline/docs/_timeline_with_gap.jsx
@@ -10,7 +10,7 @@ const TimelineWithGap = (props) => (
(
(
(
{
@@ -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)) {
@@ -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')
@@ -558,7 +567,7 @@ 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) => {
@@ -566,7 +575,7 @@ const PROP_INLINE_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => {[
},
minHeightProps: ({ minHeight }: MinHeight) => {
- return minHeight ? { minHeight } : {};
+ return minHeight ? { minHeight } : {};
},
}
diff --git a/playbook/lib/playbook/classnames.rb b/playbook/lib/playbook/classnames.rb
index 0018bf6558..2230140dd4 100644
--- a/playbook/lib/playbook/classnames.rb
+++ b/playbook/lib/playbook/classnames.rb
@@ -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,
diff --git a/playbook/lib/playbook/spacing.rb b/playbook/lib/playbook/spacing.rb
index 3d37357879..e5a9193194 100644
--- a/playbook/lib/playbook/spacing.rb
+++ b/playbook/lib/playbook/spacing.rb
@@ -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
@@ -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",
@@ -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