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

Updated Selectable Icon dark mode #955

Merged
merged 4 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Updated
- Dark Mode update to Selectable Icon kit ([#955](https://github.com/powerhome/playbook/pull/955) @kellyeryan)

### Added
- Global Prop Additions & Dark Mode Enabled ([#942](https://github.com/powerhome/playbook/pull/942) @jasperfurniss)
- Gauge Kit ([#910](https://github.com/powerhome/playbook/pull/910) @bh247484)
Expand Down
18 changes: 8 additions & 10 deletions app/pb_kits/playbook/pb_selectable_icon/_selectable_icon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import {
buildDataProps,
} from '../utilities/props'

import { globalProps } from '../utilities/globalProps.js'

type SelectableIconProps = {
aria?: Object,
checked?: Boolean,
className?: String,
disabled?: Boolean,
dark?: Boolean,
data?: Object,
icon: String,
inputId: String,
Expand All @@ -30,7 +31,6 @@ const SelectableIcon = ({
aria = {},
className,
checked = false,
dark = false,
data = {},
disabled = false,
icon,
Expand All @@ -45,13 +45,11 @@ const SelectableIcon = ({
const ariaProps = buildAriaProps(aria)
const dataProps = buildDataProps(data)

const css = buildCss({
'pb_selectable_icon_kit': true,
'checked': checked,
'dark': dark,
'disabled': disabled,
'enabled': !disabled,
})
const classes = classnames(buildCss('pb_selectable_icon_kit',
{ 'checked': checked,
'disabled': disabled,
'enabled': !disabled },
className), globalProps(props))

const inputType = multi === false ? 'radio' : 'checkbox'

Expand All @@ -61,7 +59,7 @@ const SelectableIcon = ({
<div
{...ariaProps}
{...dataProps}
className={classnames(css, className)}
className={classes}
>
<If condition={inputs === 'disabled'}>
<>
Expand Down
8 changes: 1 addition & 7 deletions app/pb_kits/playbook/pb_selectable_icon/selectable_icon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class SelectableIcon

# Icon props
prop :icon, type: Playbook::Props::String
prop :dark, type: Playbook::Props::Boolean,
default: false
# Title text
prop :text, type: Playbook::Props::String

Expand All @@ -30,7 +28,7 @@ class SelectableIcon
default: "enabled"

def classname
generate_classname("pb_selectable_icon_kit", checked_class, dark_class, enabled_disabled_class)
generate_classname("pb_selectable_icon_kit", checked_class, enabled_disabled_class)
end

def input_id_present
Expand All @@ -43,10 +41,6 @@ def checked_class
checked ? "checked" : nil
end

def dark_class
dark ? "dark" : nil
end

def enabled_disabled_class
disabled ? "disabled" : "enabled"
end
Expand Down
2 changes: 1 addition & 1 deletion spec/pb_kits/playbook/kits/selectable_icon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
it "returns namespaced class name", :aggregate_failures do
expect(subject.new({}).classname).to eq "pb_selectable_icon_kit_enabled"
expect(subject.new(classname: "additional_class").classname).to eq "pb_selectable_icon_kit_enabled additional_class"
expect(subject.new(dark: true).classname).to eq "pb_selectable_icon_kit_dark_enabled dark"
expect(subject.new(dark: true).classname).to eq "pb_selectable_icon_kit_enabled dark"
expect(subject.new(disabled: true).classname).to eq "pb_selectable_icon_kit_disabled"
end
end
Expand Down