Skip to content

Commit

Permalink
Merge branch 'master' into PLAY-1618-font-awesome-setup-docs-phase-1
Browse files Browse the repository at this point in the history
  • Loading branch information
kangaree authored Nov 1, 2024
2 parents 18dfb84 + f8db614 commit b4e09c7
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
3 changes: 1 addition & 2 deletions playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ $pb_card_header_colors: map-merge(map-merge($product_colors, $additional_colors)

@mixin pb_card_selected($border_color: $primary) {
border-color: $border_color;
border-width: $pb_card_border_width;
outline: 1px solid $border_color;
border-width: $pb_card_border_width * 2;
}

@mixin pb_card_selected_dark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
$pb_selectable_card_indicator_size: 22px;
$pb_selectable_card_border: 2px;

$pb_selectable_space_classes: (
xxs: $space_xxs,
xs: $space_xs,
sm: $space_sm,
md: $space_md,
lg: $space_lg,
xl: $space_xl,
);
$pb_selectable_paddings: (
p: "padding",
pr: "padding-right",
pl: "padding-left",
pt: "padding-top",
pb: "padding-bottom",
px: ("padding-left", "padding-right"),
py: ("padding-top", "padding-bottom")
);

[class^=pb_selectable_card_kit] {
display: block;
margin-bottom: 0;
Expand All @@ -28,7 +46,6 @@ $pb_selectable_card_border: 2px;
padding: $space_sm;
margin-bottom: $space_sm;
cursor: pointer;
outline: 1px solid transparent;

@media (hover:hover) {
&:hover {
Expand Down Expand Up @@ -74,6 +91,7 @@ $pb_selectable_card_border: 2px;

position: relative;
@include pb_card_selected;
padding: calc(#{$space_sm} - 1px);
transition-property: none;
transition-duration: 0s;

Expand All @@ -88,6 +106,54 @@ $pb_selectable_card_border: 2px;
background-color: $royal;
}
}

// Selected card has 1px more border
// Remove 1px so content does not "jump"
@each $position_name,
$position in $pb_selectable_paddings {
@each $space_name,
$space in $pb_selectable_space_classes {
~ label.#{$position_name}_#{$space_name} {
@if type-of($position)=="list" {
@each $coordinate in $position {
#{$coordinate}: calc(#{$space} - 1px) !important;
}
}

@else {
#{$position}: calc(#{$space} - 1px) !important;
}
}
}
}
}
}

&.display_input {
input[type="checkbox"],
input[type="radio"] {
&:checked {
~label {
border-width: $pb_card_border_width;
outline: 1px solid $primary;
}

}
}

> label {
outline: 1px solid transparent;
padding: $space_sm;
}

&.dark {
input[type="checkbox"],
input[type="radio"] {
&:checked ~ label {
border-width: $pb_card_border_width;
outline: 1px solid $primary;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const SelectableCard = (props: SelectableCardProps) => {
'disabled': disabled,
'enabled': !disabled,
}),
variant === 'displayInput' ? 'display_input' : '',
{ error },
dark ? 'dark' : '',
className
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<% end %>
<div class="separator"></div>
<div class="psuedo_separator"></div>
<%= pb_rails("card", props: { padding: "sm", status: object.status, border_none: true }) do %>
<%= pb_rails("card", props: { padding: "sm", status: object.status, border_none: true, dark: object.dark }) do %>
<% if content.nil? %>
<%= pb_rails("body", props: { text: object.text }) %>
<% else %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SelectableCard < Playbook::KitBase

def classname
[
generate_classname_without_spacing("pb_selectable_card_kit", checked_class, enable_disabled_class),
generate_classname_without_spacing("pb_selectable_card_kit", checked_class, enable_disabled_class) + display_input_class,
error_class,
dark_props,
].compact.join(" ")
Expand Down Expand Up @@ -79,6 +79,10 @@ def enable_disabled_class
def error_class
error ? "error" : nil
end

def display_input_class
variant == "display_input" ? " display_input" : ""
end
end
end
end

0 comments on commit b4e09c7

Please sign in to comment.