Skip to content

Commit

Permalink
[PLAY-1485] Fix overflow container bug by using padding instead of ou…
Browse files Browse the repository at this point in the history
…tline (#3807)

**What does this PR do?**

In [PLAY-829](https://runway.powerhrg.com/backlog_items/PLAY-829), we
removed the buffer to fix content alignment issues and added an outline
so the content would not 'jump' (which was handled originally by the
buffer).

- Fix overflow container bug by using padding instead of outline
- Subtract 1px of padding in the selected label container to account for
the extra 1px border of selected label
- Do this for all padding sizes xxs to xl
- For "selectable cards", keep an outline as the content is different (a
padding 0 div wrapped around flex and cards)
- Fix the dark mode for rails and apply it to the card

**Screenshots:** Screenshots to visualize your addition/change
![Screenshot 2024-10-30 at 10 25
07 AM](https://github.com/user-attachments/assets/68b7efcf-3775-4d15-b70d-cce39b40f698)

![Screenshot 2024-10-23 at 9 15
54 AM](https://github.com/user-attachments/assets/a447bd7b-2bbb-4aa0-97b8-d7804bc7a19c)


**How to test?** Steps to confirm the desired behavior:
1. Go to the Playbook Website
2. Go to the Selectable Card kit
3. Click the cards
4. Make sure the content does not "jump" or shift around and stays in
place
5. Go to the Nitro test env
6. Use the Impersonation Flyout
7. Search by title so multiple results show (e.g., "Nitro Quality
Ninja")
8. The selected card should not be cut off
9. If you select a card, the content should not "jump" or shift around
10. Since there are multiple employees, everything should fit in the
overlay- the impersonate and cancel button should fit on the overlay and
not be below a scroll.

#### 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.
  • Loading branch information
kangaree authored Oct 31, 2024
1 parent c965ab7 commit f8db614
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 f8db614

Please sign in to comment.