Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PBNTR-389](Dropdown work - States & Variant Prop [ 1 of 5]) #3736

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@

&[class*="_list"] {
border-bottom: 1px solid $border_light;

&:hover, &:focus {
.pb_body_kit {
color: $primary;
}
}
}
&[class*="selected"] {
background-color: $primary;
Expand All @@ -87,7 +93,7 @@
color: $white !important;
}
&:hover {
background-color: $primary !important;
background-color: $product_1_background !important;
}
}
}
Expand Down Expand Up @@ -184,4 +190,27 @@
}
}
}
}

&.subtle {
.dropdown_wrapper {
.pb_dropdown_container {

[class*="pb_dropdown_option"]:first-child {
padding-top: $space_xs;
}

[class*="pb_dropdown_option"]:last-child {
padding-bottom: $space_xs;
}

[class*="pb_dropdown_option"] {
padding-left: $space_xs;
padding-right: $space_xs;
padding-top: 2px;
padding-bottom: 2px;
border: none;
}
}
}
}
}
5 changes: 4 additions & 1 deletion playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type DropdownProps = {
onSelect?: (arg: GenericObject) => null;
options: GenericObject;
triggerRef?: any;
variant?: "primary" | "subtle";
nidaqg marked this conversation as resolved.
Show resolved Hide resolved
};

const Dropdown = (props: DropdownProps) => {
Expand All @@ -55,7 +56,8 @@ const Dropdown = (props: DropdownProps) => {
label,
onSelect,
options,
triggerRef
triggerRef,
variant = "primary"
} = props;

const ariaProps = buildAriaProps(aria);
Expand All @@ -64,6 +66,7 @@ const Dropdown = (props: DropdownProps) => {
const classes = classnames(
buildCss("pb_dropdown"),
globalProps(props),
variant,
className
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%
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, variant: "subtle"}) %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react'
import { Dropdown } from 'playbook-ui'

const DropdownSubtleVariant = (props) => {

const options = [
{
label: "United States",
value: "United States",
},
{
label: "Canada",
value: "Canada",
},
{
label: "Pakistan",
value: "Pakistan",
}
];


return (
<>
<Dropdown
options={options}
variant="subtle"
{...props}
/>
</>
)
}

export default DropdownSubtleVariant
2 changes: 2 additions & 0 deletions playbook/app/pb_kits/playbook/pb_dropdown/docs/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ examples:
- dropdown_error: Dropdown with Error
- dropdown_default_value: Default Value
- dropdown_blank_selection: Blank Selection
- dropdown_subtle_variant: Subtle Variant

react:
- dropdown_default: Default
Expand All @@ -22,6 +23,7 @@ examples:
- dropdown_error: Dropdown with Error
- dropdown_default_value: Default Value
- dropdown_blank_selection: Blank Selection
- dropdown_subtle_variant: Subtle Variant
# - dropdown_with_autocomplete: Autocomplete
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
# - dropdown_with_external_control: useDropdown Hook
Expand Down
1 change: 1 addition & 0 deletions playbook/app/pb_kits/playbook/pb_dropdown/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export { default as DropdownSubcomponentStructure } from './_dropdown_subcompone
export { default as DropdownError } from './_dropdown_error.jsx'
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
export { default as DropdownBlankSelection } from './_dropdown_blank_selection.jsx'
export { default as DropdownSubtleVariant } from './_dropdown_subtle_variant.jsx'
5 changes: 4 additions & 1 deletion playbook/app/pb_kits/playbook/pb_dropdown/dropdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ class Dropdown < Playbook::KitBase
prop :default_value
prop :blank_selection, type: Playbook::Props::String,
default: ""
prop :variant, type: Playbook::Props::Enum,
values: %w[primary subtle],
default: "primary"

def data
Hash(prop(:data)).merge(pb_dropdown: true)
end

def classname
generate_classname("pb_dropdown")
generate_classname("pb_dropdown", variant, separator: " ")
end

private
Expand Down
Loading