Skip to content

Commit

Permalink
Merge branch 'master' into play/1587_group_hover_global_prop
Browse files Browse the repository at this point in the history
  • Loading branch information
markdoeswork authored Oct 23, 2024
2 parents 515d9dd + 70085cc commit ce47dd5
Show file tree
Hide file tree
Showing 44 changed files with 1,418 additions and 1,000 deletions.
2 changes: 1 addition & 1 deletion playbook-website/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: ../playbook
specs:
playbook_ui (14.5.0)
playbook_ui (14.6.0)
actionpack (>= 5.2.4.5)
actionview (>= 5.2.4.5)
activesupport (>= 5.2.4.5)
Expand Down
2 changes: 1 addition & 1 deletion playbook/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
playbook_ui (14.5.0)
playbook_ui (14.6.0)
actionpack (>= 5.2.4.5)
actionview (>= 5.2.4.5)
activesupport (>= 5.2.4.5)
Expand Down
2 changes: 2 additions & 0 deletions playbook/app/entrypoints/playbook-rails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Forms
import 'kits/pb_form/pb_form_validation'
import formHelper from 'kits/pb_form/formHelper'
window.formHelper = formHelper

// Date Picker
import datePickerHelper from 'kits/pb_date_picker/date_picker_helper'
Expand Down
2 changes: 2 additions & 0 deletions playbook/app/javascript/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export { default as PbTextarea } from '../pb_kits/playbook/pb_textarea'
export { default as PbTooltip } from '../pb_kits/playbook/pb_tooltip'
export { default as PbTypeahead } from '../pb_kits/playbook/pb_typeahead'
export { default as dialogHelper } from '../pb_kits/playbook/pb_dialog/dialogHelper'
export { default as formHelper } from '../pb_kits/playbook/pb_form/formHelper'

Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
<%= pb_rails("button", props: { text: "Open Dialog", data: {"open-dialog": "dialog-loading"} }) %>
<%= pb_rails("dialog", props: {
id:"dialog-loading",
size: "sm",
title: "Loading Exmaple",
text: "Make a loading request?",
cancel_button: "Cancel Button",
<%= pb_rails("dialog", props: {
id:"dialog-loading",
size: "sm",
title: "Loading Example",
text: "Make a loading request?",
cancel_button: "Cancel Button",
cancel_button_id: "cancel-button-loading",
confirm_button: "Okay",
confirm_button: "Okay",
confirm_button_id: "confirm-button-loading",
loading: true,
}) %>

<script>
const loadingButton = document.querySelector('[data-disable-with="Loading"]');
if (loadingButton) {
loadingButton.addEventListener("click", function() {
const okayLoadingButton = document.querySelector('[data-disable-with="Loading"]');
const cancelButton = document.querySelector('[data-disable-cancel-with="Loading"]');
let currentClass = okayLoadingButton.className;
let cancelClass = cancelButton ? cancelButton.className : "";

setTimeout(function() {
okayLoadingButton.disabled = false;
okayLoadingButton.className = currentClass.replace("_disabled_loading", "_enabled");

if (cancelButton) {
cancelButton.disabled = false;
cancelButton.className = cancelClass.replace("_disabled", "_enabled");
}
}, 5000);

});
}
</script>
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Pressing the "Okay" button will trigger a loading state where the button content is replaced by a spinner icon and both buttons are disabled.

Currently, the loading state cannot be undone and will require a page refresh to reset the dialog.
87 changes: 84 additions & 3 deletions playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -87,7 +93,7 @@
color: $white !important;
}
&:hover {
background-color: $primary !important;
background-color: $product_1_background !important;
}
}
}
Expand Down Expand Up @@ -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"] {
Expand Down
9 changes: 8 additions & 1 deletion playbook/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ type DropdownProps = {
label?: string;
onSelect?: (arg: GenericObject) => null;
options: GenericObject;
separators: boolean;
triggerRef?: any;
variant?: "default" | "subtle";
};

interface DropdownComponent
Expand All @@ -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
);

Expand Down
Original file line number Diff line number Diff line change
@@ -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}) %>
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<Dropdown
options={options}
separators={false}
{...props}
/>
</div>
)
}

export default DropdownSeparatorsHidden
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", separators: false }) %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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}
separators={false}
variant="subtle"
{...props}
/>
</>
)
}

export default DropdownSubtleVariant
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a more cleaner look.
4 changes: 4 additions & 0 deletions playbook/app/pb_kits/playbook/pb_dropdown/docs/example.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
examples:
rails:
- dropdown_default: Default
- dropdown_subtle_variant: Subtle Variant
- dropdown_subcomponent_structure_rails: Subcomponent Structure
- dropdown_with_label: With Label
- dropdown_with_custom_options_rails: Custom Options
Expand All @@ -10,9 +11,11 @@ examples:
- dropdown_error: Dropdown with Error
- dropdown_default_value: Default Value
- dropdown_blank_selection: Blank Selection
- dropdown_separators_hidden: Separators Hidden

react:
- dropdown_default: Default
- dropdown_subtle_variant: Subtle Variant
- dropdown_subcomponent_structure: Subcomponent Structure
- dropdown_with_label: With Label
- dropdown_with_custom_options: Custom Options
Expand All @@ -23,6 +26,7 @@ examples:
- dropdown_default_value: Default Value
- dropdown_blank_selection: Blank Selection
- dropdown_clear_selection: Clear Selection
- dropdown_separators_hidden: Separators Hidden
# - dropdown_with_autocomplete: Autocomplete
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
# - dropdown_with_external_control: useDropdown Hook
Expand Down
2 changes: 2 additions & 0 deletions playbook/app/pb_kits/playbook/pb_dropdown/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ 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 DropdownClearSelection } from './_dropdown_clear_selection.jsx'
export { default as DropdownSubtleVariant } from './_dropdown_subtle_variant.jsx'
export { default as DropdownSeparatorsHidden } from './_dropdown_separators_hidden.jsx'
11 changes: 10 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,18 @@ class Dropdown < Playbook::KitBase
prop :default_value
prop :blank_selection, type: Playbook::Props::String,
default: ""
prop :variant, type: Playbook::Props::Enum,
values: %w[default subtle],
default: "default"
prop :separators, type: Playbook::Props::Boolean,
default: true

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

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

private
Expand All @@ -32,6 +37,10 @@ def input_default_value
default_value.present? ? default_value.transform_keys(&:to_s)["id"] : ""
end

def separators_class
separators ? "" : "separators_hidden"
end

def options_with_blank
blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + options : options
end
Expand Down
Loading

0 comments on commit ce47dd5

Please sign in to comment.