diff --git a/src/Button/ToggleButton/ToggleButton.example.md b/src/Button/ToggleButton/ToggleButton.example.md index 7d5959bf3..11efd86c9 100644 --- a/src/Button/ToggleButton/ToggleButton.example.md +++ b/src/Button/ToggleButton/ToggleButton.example.md @@ -75,3 +75,39 @@ const StandaloneToggleButton = () => { ``` + +A ToggleButton with a different type and a customized theme: + +```jsx +import ToggleButton from '@terrestris/react-geo/dist/Button/ToggleButton/ToggleButton'; +import {ConfigProvider} from 'antd'; +import * as React from 'react'; + +const StandaloneToggleButton = () => { + const [pressed, setPressed] = React.useState(); + + return ( + + setPressed(!pressed)} + > + Toggle me + + + ); +}; + + +``` diff --git a/src/Button/ToggleButton/ToggleButton.less b/src/Button/ToggleButton/ToggleButton.less new file mode 100644 index 000000000..cc0c203be --- /dev/null +++ b/src/Button/ToggleButton/ToggleButton.less @@ -0,0 +1,25 @@ +.react-geo-togglebutton.btn-pressed.ant-btn-primary { + color: var(--ant-color-text-light-solid, #fff); + background: var(--ant-color-primary-active, #0958d9); +} + +.react-geo-togglebutton.btn-pressed.ant-btn-default { + color: var(--ant-button-default-active-color, #0958d9); + border-color: var(--ant-button-default-active-border-color, #0958d9); + background: var(--ant-button-default-active-bg, #ffffff); +} + +.react-geo-togglebutton.btn-pressed.ant-btn-link { + color: var(--ant-color-link-active, #0958d9); +} + +.react-geo-togglebutton.btn-pressed.ant-btn-dashed { + color: var(--ant-button-default-active-color, #0958d9); + border-color: var(--ant-button-default-active-border-color, #0958d9); + background: var(--ant-button-default-active-bg, #ffffff); +} + +.react-geo-togglebutton.btn-pressed.ant-btn-text { + color: var(--ant-color-text, rgba(0, 0, 0, 0.88)); + background: var(--ant-color-bg-text-active, rgba(0, 0, 0, 0.15)); +} diff --git a/src/Button/ToggleButton/ToggleButton.tsx b/src/Button/ToggleButton/ToggleButton.tsx index bd00fec0c..e7fdabc3e 100644 --- a/src/Button/ToggleButton/ToggleButton.tsx +++ b/src/Button/ToggleButton/ToggleButton.tsx @@ -1,6 +1,7 @@ +import './ToggleButton.less'; + import { Button, - theme, Tooltip } from 'antd'; import { @@ -11,10 +12,6 @@ import React, { MouseEvent } from 'react'; -const { useToken } = theme; - -import _isFunction from 'lodash/isFunction'; - import { CSS_PREFIX } from '../../constants'; import { SimpleButtonProps } from '../SimpleButton/SimpleButton'; @@ -58,11 +55,6 @@ interface OwnProps { * The onChange callback. */ onChange?: (evt: MouseEvent, value?: string) => void; - - /** - * Sets button background to transparent instead of primary color. - */ - buttonTransparent?: boolean; } export type ToggleButtonProps = OwnProps & Omit; @@ -82,12 +74,9 @@ export const ToggleButton: React.FC = ({ value, onClick, onChange = () => {}, - buttonTransparent = false, ...passThroughProps }) => { - const token = useToken(); - const handleChange = (evt: React.MouseEvent) => { if (onClick) { onClick(evt); @@ -118,14 +107,6 @@ export const ToggleButton: React.FC = ({ {...tooltipProps} >