Skip to content

Commit

Permalink
Feature/hadas/toggle color (#166)
Browse files Browse the repository at this point in the history
* css: toggle apperance when disable

* fix disable apperance
  • Loading branch information
Hadas Farhi authored Jul 13, 2021
1 parent 79b814d commit 498dcb0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
23 changes: 14 additions & 9 deletions src/components/Toggle/Toggle.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
import cx from "classnames";
import NOOP from "lodash/noop";
import { BASE_TOGGLE_CLASS_NAME } from "./ToggleConstants";
import ToggleText from "./ToggleText";
Expand Down Expand Up @@ -37,17 +37,22 @@ const Toggle = ({
ariaControls
});

const className = classNames(bemHelper({ element: "toggle" }), componentClassName, {
[bemHelper({ element: "toggle", state: "selected" })]: isChecked,
[bemHelper({ element: "toggle", state: "not-selected" })]: !isChecked,
[bemHelper({ element: "toggle", state: "disabled" })]: isDisabled
});

return (
<label htmlFor={id} className={bemHelper({ element: "wrapper" })}>
<label
htmlFor={id}
className={cx(bemHelper({ element: "wrapper" }), {
[bemHelper({ element: "wrapper", state: "disabled" })]: isDisabled
})}
>
{areLabelsHidden ? null : <ToggleText>{offOverrideText}</ToggleText>}
<input {...inputProps} className={bemHelper({ element: "input" })} />
<div className={className} aria-hidden="true" />
<div
className={cx(bemHelper({ element: "toggle" }), componentClassName, {
[bemHelper({ element: "toggle", state: "selected" })]: isChecked,
[bemHelper({ element: "toggle", state: "not-selected" })]: !isChecked
})}
aria-hidden="true"
/>
{areLabelsHidden ? null : <ToggleText>{onOverrideText}</ToggleText>}
</label>
);
Expand Down
10 changes: 6 additions & 4 deletions src/components/Toggle/Toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
&_wrapper {
display: flex;
align-items: center;
&--disabled {
opacity: 0.4;
& .monday-style-toggle_text {
color: rgba(var(--primary-text-color), 0.4);
}
}
}

// Since it is not possible to change the design of the checkbox according to the storybook toggle requirements using css,
Expand Down Expand Up @@ -57,10 +63,6 @@
left: 3px;
}
}

&--disabled {
@include theme-prop(background-color, primary-background-hover-color);
}
}

&_text {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toggle/ToggleText.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { BASE_TOGGLE_CLASS_NAME } from "./ToggleConstants";

const ToggleText = ({ children }) => <span className={`${BASE_TOGGLE_CLASS_NAME}__text`}>{children}</span>;
const ToggleText = ({ children }) => <span className={`${BASE_TOGGLE_CLASS_NAME}_text`}>{children}</span>;
export default ToggleText;

0 comments on commit 498dcb0

Please sign in to comment.