-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1082fe0
commit ddd7612
Showing
21 changed files
with
718 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/@ourworldindata/grapher/src/controls/RadioButton.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.radio { | ||
$radio-size: 16px; | ||
|
||
$light-stroke: #a4b6ca; | ||
$active-fill: #6e87a2; | ||
|
||
position: relative; | ||
|
||
input { | ||
position: absolute; | ||
opacity: 0; | ||
left: 0; | ||
cursor: pointer; | ||
pointer-events: none; | ||
} | ||
|
||
.outer { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: $radio-size; | ||
height: $radio-size; | ||
|
||
background: white; | ||
pointer-events: none; | ||
border-radius: 50%; | ||
border: 1px solid $light-stroke; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
.inner { | ||
width: $radio-size / 2; | ||
height: $radio-size / 2; | ||
background-color: $active-fill; | ||
border-radius: 50%; | ||
} | ||
} | ||
|
||
input:focus-visible + .outer { | ||
outline: 2px solid $controls-color; | ||
} | ||
|
||
.label { | ||
@include grapher_label-2-regular; | ||
padding-left: $radio-size + 8px; | ||
cursor: pointer; | ||
user-select: none; | ||
color: $dark-text; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/@ourworldindata/grapher/src/controls/RadioButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from "react" | ||
|
||
export class RadioButton extends React.Component<{ | ||
checked: boolean | ||
onChange: React.ChangeEventHandler<HTMLInputElement> | ||
label: React.ReactNode | ||
group?: string | ||
}> { | ||
render(): JSX.Element { | ||
const { checked, onChange, label, group } = this.props | ||
|
||
return ( | ||
<div className="radio"> | ||
<label> | ||
<input | ||
type="radio" | ||
name={group} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
<div className="outer"> | ||
{checked && <div className="inner" />} | ||
</div> | ||
<div className="label">{label}</div> | ||
</label> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.