diff --git a/playbook/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss b/playbook/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss new file mode 100644 index 0000000000..0518a8f4f8 --- /dev/null +++ b/playbook/app/pb_kits/playbook/pb_form_group/_error_state_mixin.scss @@ -0,0 +1,57 @@ +@mixin error-state-flex-start-selectors { + &:has(.pb_text_input_kit.error):has(.pb_text_input_kit), + &:has(.pb_text_input_kit):has(.pb_date_picker_kit.error), + &:has(.pb_text_input_kit):has(.pb_select_kit_wrapper.error), + &:has(.pb_text_input_kit.error):has(.pb_text_input_kit_label):has(.pb_select_kit_wrapper.error) { + align-items: flex-start; + } +} + +@mixin error-state-center-selectors { + &:has(.pb_select_kit_label):has(.pb_select_kit_wrapper.error):has(.pb_phone_number_input), + &:has(.pb_text_input_kit.error):has(.pb_text_input_kit_label):has([class^=pb_button_kit]) { + align-items: center; + } +} + +@mixin error-state-flex-end-selectors { + &:has(.pb_select_kit_label):has(.pb_select_kit_wrapper.error):has(.pb_phone_number_input):has(.pb_text_input_kit.error) { + align-items: flex-end; + } +} + +@mixin error-state-right-side-select-kit { + &:has(.pb_text_input_kit:not(.error)):has(.pb_text_input_kit_label):has(.pb_select_kit_wrapper.error), + &:has(.pb_text_input_kit.error):has(.pb_text_input_kit_label):has(.pb_select_kit_wrapper) { + align-items: flex-start; + + .pb_select_kit_wrapper { + padding-top: $space_md; + margin-top: 2px; + + .pb_select_kit_caret { + padding-top: $space_md; + } + } + + .pb_select_kit_wrapper.error { + padding-top: $space_md; + margin-top: 2px; + + .pb_select_kit_caret { + padding-top: $space_xl; + } + } + } +} + +@mixin error-state-left-side-select-kit { + &:has(.pb_select_kit_label):has(.pb_select_kit_wrapper):has(.pb_phone_number_input):has(.pb_text_input_kit.error) { + align-items: flex-start; + + .pb_text_input_kit.error { + padding-top: $space_md; + margin-top: 2px; + } + } +} diff --git a/playbook/app/pb_kits/playbook/pb_form_group/_form_group.scss b/playbook/app/pb_kits/playbook/pb_form_group/_form_group.scss index 926ba8b65a..009e50908b 100644 --- a/playbook/app/pb_kits/playbook/pb_form_group/_form_group.scss +++ b/playbook/app/pb_kits/playbook/pb_form_group/_form_group.scss @@ -1,3 +1,6 @@ +@import "../tokens/spacing"; +@import "./error_state_mixin"; + [class^=pb_form_group_kit] { display: inline-flex; flex-direction: row; @@ -12,6 +15,12 @@ } } +@include error-state-flex-start-selectors; +@include error-state-center-selectors; +@include error-state-flex-end-selectors; +@include error-state-left-side-select-kit; +@include error-state-right-side-select-kit; + & [class^=pb_text_input_kit] .text_input_wrapper, & [class^=pb_date_picker_kit] .input_wrapper, & [class^=pb_select] { @@ -27,7 +36,7 @@ border-bottom-right-radius: 0; border-top-right-radius: 0; border-right-width: 0; - + &:focus { outline: $primary solid 1px; outline-offset: -1px; @@ -150,7 +159,7 @@ & > [class^=pb_selectable_card_kit] input[type="checkbox"]:not(:checked) ~ label, [class^=pb_selectable_card_kit] input[type="radio"]:not(:checked) ~ label { &:hover { border-right-color: $slate; - } + } } & > [class^=pb_selectable_card_kit]:not(:first-child) label {