From f4c5e2fd7f91cf286220ea89f16ae0c7b6b87f3b Mon Sep 17 00:00:00 2001 From: Nick Amantia <92755007+nickamantia@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:35:56 -0400 Subject: [PATCH] [PBNTR-389](Dropdown work - States & Variant Prop [ 1 of 5]) (#3828) [PBNTR-389](https://runway.powerhrg.com/backlog_items/PBNTR-389) This PR adds new state styles and a variant prop with a subtle doc example! **How to test?** Steps to confirm the desired behavior: 1. Go to the dropdown kit and confirm styles! #### 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. - [ ] **TESTS** I have added test coverage to my code. --- .../playbook/pb_dropdown/_dropdown.scss | 87 ++++++++++++++++++- .../playbook/pb_dropdown/_dropdown.tsx | 9 +- .../docs/_dropdown_separators_hidden.html.erb | 9 ++ .../docs/_dropdown_separators_hidden.jsx | 33 +++++++ .../docs/_dropdown_subtle_variant.html.erb | 10 +++ .../docs/_dropdown_subtle_variant.jsx | 34 ++++++++ .../docs/_dropdown_subtle_variant.md | 1 + .../playbook/pb_dropdown/docs/example.yml | 4 + .../playbook/pb_dropdown/docs/index.js | 2 + .../pb_kits/playbook/pb_dropdown/dropdown.rb | 11 ++- 10 files changed, 195 insertions(+), 5 deletions(-) create mode 100644 playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.html.erb create mode 100644 playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.jsx create mode 100644 playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.html.erb create mode 100644 playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.jsx create mode 100644 playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.md diff --git a/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss b/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss index a64e52f2aa..05b26b4b07 100644 --- a/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +++ b/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss @@ -69,15 +69,21 @@ padding-bottom: $space_xs; cursor: pointer; &:hover { - background-color: $border_light; + background-color: $bg_light; } &[class*="_focused"] { - background-color: $border_light; + background-color: $bg_light; } &[class*="_list"] { border-bottom: 1px solid $border_light; + + &:hover, &:focus { + .pb_body_kit { + color: $primary; + } + } } &[class*="selected"] { background-color: $primary; @@ -87,7 +93,7 @@ color: $white !important; } &:hover { - background-color: $primary !important; + background-color: $product_1_background !important; } } } @@ -125,6 +131,81 @@ } } + &.separators_hidden { + .dropdown_wrapper { + .pb_dropdown_container { + + [class*="pb_dropdown_option"] { + border: none; + } + } + } + } + + &.subtle { + .dropdown_wrapper { + .pb_dropdown_container { + + [class*="pb_dropdown_option"]:first-child { + margin-top: $space_xs; + } + + [class*="pb_dropdown_option"]:last-child { + margin-bottom: $space_xs; + } + + [class*="pb_dropdown_option"] { + margin: $space_xs; + padding: $space_xs; + border-radius: $border_radius_md; + border-bottom: none; + position: relative; + + &::after { + content: ""; + position: absolute; + left: -$space_xs; + right: -$space_xs; + bottom: -4.5px; + height: 1px; + background: $border_light; + } + } + + [class*="pb_dropdown_option"]:last-child::after { + display: none; + } + } + } + + &.separators_hidden { + .dropdown_wrapper { + .pb_dropdown_container { + [class*="pb_dropdown_option"]:first-child { + margin-top: $space_xs; + } + + [class*="pb_dropdown_option"]:last-child { + margin-bottom: $space_xs; + } + + [class*="pb_dropdown_option"] { + padding: $space_xxs $space_xs; + margin: $space_xxs $space_xs; + + &::after { + height: 0px; + } + + &[class*="selected"] { + border-bottom: none; + } + } + } + } + } + } + &.dark { .dropdown_wrapper { [class*="dropdown_trigger_wrapper"] { diff --git a/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx b/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx index 27234c3fec..28af6eb76a 100644 --- a/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +++ b/playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx @@ -35,7 +35,9 @@ type DropdownProps = { label?: string; onSelect?: (arg: GenericObject) => null; options: GenericObject; + separators: boolean; triggerRef?: any; + variant?: "default" | "subtle"; }; interface DropdownComponent @@ -62,15 +64,20 @@ const Dropdown = forwardRef((props: DropdownProps, ref: any) => { label, onSelect, options, - triggerRef + separators = true, + triggerRef, + variant = "default", } = props; const ariaProps = buildAriaProps(aria); const dataProps = buildDataProps(data); const htmlProps = buildHtmlProps(htmlOptions); + const separatorsClass = separators ? '' : 'separators_hidden' const classes = classnames( buildCss("pb_dropdown"), globalProps(props), + variant, + separatorsClass, className ); diff --git a/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.html.erb b/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.html.erb new file mode 100644 index 0000000000..98d2b41939 --- /dev/null +++ b/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.html.erb @@ -0,0 +1,9 @@ +<% + options = [ + { label: 'United States', value: 'United States', id: 'us' }, + { label: 'Canada', value: 'Canada', id: 'ca' }, + { label: 'Pakistan', value: 'Pakistan', id: 'pk' }, + ] + +%> +<%= pb_rails("dropdown", props: {options: options, separators: false}) %> \ No newline at end of file diff --git a/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.jsx b/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.jsx new file mode 100644 index 0000000000..053c60e339 --- /dev/null +++ b/playbook/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_separators_hidden.jsx @@ -0,0 +1,33 @@ +import React from 'react' +import { Dropdown } from 'playbook-ui' + +const DropdownSeparatorsHidden = (props) => { + + const options = [ + { + label: "United States", + value: "United States", + }, + { + label: "Canada", + value: "Canada", + }, + { + label: "Pakistan", + value: "Pakistan", + } + ]; + + + return ( +