Skip to content

Commit

Permalink
use standard bem for styling
Browse files Browse the repository at this point in the history
  • Loading branch information
eszthoff committed Dec 8, 2021
1 parent 98c2cf1 commit bff4f01
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
26 changes: 13 additions & 13 deletions src/components/DatePicker/CalendarHeader/CalendarHeader.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
.container {
.CalendarHeader {
display: flex;
justify-content: space-between;
align-items: baseline;
}

.navButton {
width: 33px;
height: 33px;
}
&__navButton {
width: 33px;
height: 33px;
}

.select {
margin-left: var(--spacing-normal);
background-color: var(--color-background);
border: 0;
font-size: var(--font-size-normal);
&__select {
margin-left: var(--spacing-normal);
background-color: var(--color-background);
border: 0;
font-size: var(--font-size-normal);

&:focus {
outline: none;
&:focus {
outline: none;
}
}
}
11 changes: 7 additions & 4 deletions src/components/DatePicker/CalendarHeader/CalendarHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { ReactDatePickerCustomHeaderProps } from 'react-datepicker';
import { ImArrowLeft2, ImArrowRight2 } from 'react-icons/im';
import { bem } from '../../../utils';
import { Button } from '../../Buttons';
import { Text } from '../../Text';
import styles from './CalendarHeader.scss';
Expand All @@ -12,6 +13,8 @@ interface Props extends ReactDatePickerCustomHeaderProps {
years: number[];
}

const { block, elem } = bem('CalendarHeader', styles);

export const CalendarHeader: React.FC<Props> = (props) => {
const {
monthsNames,
Expand All @@ -25,11 +28,11 @@ export const CalendarHeader: React.FC<Props> = (props) => {
} = props;

return (
<div className={styles.container}>
<div {...block()}>
<Button
onClick={decreaseMonth}
disabled={prevMonthButtonDisabled}
className={styles.navButton}
{...elem('navButton')}
>
<ImArrowLeft2 />
</Button>
Expand All @@ -38,7 +41,7 @@ export const CalendarHeader: React.FC<Props> = (props) => {
{monthsNames[date.getMonth()]}
</Text>
<select
className={styles.select}
{...elem('select')}
value={date.getFullYear()}
onChange={({ target: { value } }) => changeYear(parseInt(value, 10))}
>
Expand All @@ -52,7 +55,7 @@ export const CalendarHeader: React.FC<Props> = (props) => {
<Button
onClick={increaseMonth}
disabled={nextMonthButtonDisabled}
className={styles.navButton}
{...elem('navButton')}
>
<ImArrowRight2 />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ exports[`CalendarHeader should render correctly 1`] = `
}
>
<div
className="container"
className="CalendarHeader"
>
<Button
className="navButton"
className="CalendarHeader__navButton"
context="neutral"
disabled={false}
isBlock={false}
Expand All @@ -51,7 +51,7 @@ exports[`CalendarHeader should render correctly 1`] = `
type="button"
>
<button
className="Button Button--context_neutral navButton"
className="Button Button--context_neutral CalendarHeader__navButton"
disabled={false}
onClick={[MockFunction]}
type="button"
Expand Down Expand Up @@ -104,7 +104,7 @@ exports[`CalendarHeader should render correctly 1`] = `
</span>
</Text>
<select
className="select"
className="CalendarHeader__select"
onChange={[Function]}
value={2021}
>
Expand Down Expand Up @@ -171,7 +171,7 @@ exports[`CalendarHeader should render correctly 1`] = `
</select>
</div>
<Button
className="navButton"
className="CalendarHeader__navButton"
context="neutral"
disabled={false}
isBlock={false}
Expand All @@ -181,7 +181,7 @@ exports[`CalendarHeader should render correctly 1`] = `
type="button"
>
<button
className="Button Button--context_neutral navButton"
className="Button Button--context_neutral CalendarHeader__navButton"
disabled={false}
onClick={[MockFunction]}
type="button"
Expand Down

0 comments on commit bff4f01

Please sign in to comment.