From 889ebd5242cca5875ffa028dde92f3b8fd1b042d Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Mon, 25 Mar 2024 09:37:46 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(entity=20selector)=20redesign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/src/Checkbox.scss | 5 +- .../components/src/Checkbox.tsx | 4 +- .../grapher/src/controls/RadioButton.scss | 72 +++ .../grapher/src/controls/RadioButton.tsx | 31 ++ .../grapher/src/core/Grapher.tsx | 13 +- .../grapher/src/core/GrapherConstants.ts | 5 +- .../grapher/src/core/grapher.scss | 1 + .../grapher/src/core/typography.scss | 33 ++ .../src/entitySelector/EntitySelector.scss | 253 +++++---- .../src/entitySelector/EntitySelector.tsx | 487 ++++++++++++------ .../grapher/src/modal/EntitySelectorModal.tsx | 2 +- .../grapher/src/modal/Modal.scss | 5 + .../grapher/src/modal/Modal.tsx | 9 +- .../grapher/src/selection/SelectionArray.ts | 24 +- .../grapher/src/sidePanel/SidePanel.scss | 4 +- .../grapher/src/sidePanel/SidePanel.tsx | 9 +- .../src/slideInDrawer/SlideInDrawer.scss | 10 +- .../src/slideInDrawer/SlideInDrawer.tsx | 13 +- .../grapher/src/slopeCharts/SlopeChart.tsx | 3 +- .../tsup.config.bundled_mna7e6rrx0j.mjs | 15 + 20 files changed, 715 insertions(+), 283 deletions(-) create mode 100644 packages/@ourworldindata/grapher/src/controls/RadioButton.scss create mode 100644 packages/@ourworldindata/grapher/src/controls/RadioButton.tsx create mode 100644 packages/@ourworldindata/grapher/tsup.config.bundled_mna7e6rrx0j.mjs diff --git a/packages/@ourworldindata/components/src/Checkbox.scss b/packages/@ourworldindata/components/src/Checkbox.scss index 04f3b3ded66..f7523480202 100644 --- a/packages/@ourworldindata/components/src/Checkbox.scss +++ b/packages/@ourworldindata/components/src/Checkbox.scss @@ -57,11 +57,10 @@ } .label { + @include grapher_label-2-regular; padding-left: $checkbox-size + 8px; cursor: pointer; - font-size: 14px; - letter-spacing: 0.01em; - line-height: 1.15; + user-select: none; } &:hover { diff --git a/packages/@ourworldindata/components/src/Checkbox.tsx b/packages/@ourworldindata/components/src/Checkbox.tsx index 0e6e799939c..207a9439003 100644 --- a/packages/@ourworldindata/components/src/Checkbox.tsx +++ b/packages/@ourworldindata/components/src/Checkbox.tsx @@ -4,8 +4,8 @@ import { faCheck } from "@fortawesome/free-solid-svg-icons" export class Checkbox extends React.Component<{ checked: boolean - onChange: () => any - label: string | React.ReactNode + onChange: React.ChangeEventHandler + label: React.ReactNode }> { render(): JSX.Element { const { checked, onChange, label } = this.props diff --git a/packages/@ourworldindata/grapher/src/controls/RadioButton.scss b/packages/@ourworldindata/grapher/src/controls/RadioButton.scss new file mode 100644 index 00000000000..addc72efe66 --- /dev/null +++ b/packages/@ourworldindata/grapher/src/controls/RadioButton.scss @@ -0,0 +1,72 @@ +.radio { + $radio-size: 16px; + + $light-stroke: #dadada; + $hover-stroke: #a4b6ca; + $active-fill: #dbe5f0; + + position: relative; + + input { + position: absolute; + opacity: 0; + left: 0; + cursor: pointer; + } + + .outer { + position: absolute; + left: 0; + top: 0; + content: " "; + width: $radio-size; + height: $radio-size; + + background: white; + pointer-events: none; + border-radius: 50%; + border: 1px solid #a4b6ca; + color: $dark-text; + + display: flex; + align-items: center; + justify-content: center; + + .inner { + display: none; + width: $radio-size / 2; + height: $radio-size / 2; + background-color: #6e87a2; + border-radius: 50%; + } + } + + input:focus-visible + .outer { + outline: 2px solid $controls-color; + } + + input:active + .outer > .inner { + display: block; + } + + input:checked + .outer > .inner { + display: block; + } + + input:checked:active + .outer > .inner { + display: block; + } + + .label { + @include grapher_label-2-regular; + padding-left: $radio-size + 8px; + cursor: pointer; + user-select: none; + } + + &:hover { + input:not(:checked) + .custom { + border-color: $hover-stroke; + } + } +} diff --git a/packages/@ourworldindata/grapher/src/controls/RadioButton.tsx b/packages/@ourworldindata/grapher/src/controls/RadioButton.tsx new file mode 100644 index 00000000000..10117e869e1 --- /dev/null +++ b/packages/@ourworldindata/grapher/src/controls/RadioButton.tsx @@ -0,0 +1,31 @@ +import React from "react" + +export class RadioButton extends React.Component<{ + checked: boolean + onChange: React.ChangeEventHandler + label: React.ReactNode + group?: string +}> { + render(): JSX.Element { + const { checked, onChange, label, group } = this.props + + return ( +
+