Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #280 from nekochans/feature/issue276/update-langua…
Browse files Browse the repository at this point in the history
…ge-button

LanguageButton をCSS Modulesを使った形に置換え
  • Loading branch information
keitakn committed May 26, 2023
2 parents 4398f83 + a092c8e commit e1c63ba
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 43 deletions.
37 changes: 37 additions & 0 deletions src/components/Header/LanguageButton.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.wrapper {
box-sizing: border-box;
display: flex;
flex: none;
flex-direction: row;
flex-grow: 0;
gap: 10px;
align-items: center;
justify-content: center;
order: 1;
padding: 12px 20px;
border-radius: 4px;
}

@media (max-width: 767px) {
.wrapper {
padding: 12px 0;
}
}

.text {
flex: none;
flex-grow: 0;
order: 0;
font-family: Roboto, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 700;
line-height: 19px;
color: var(--primary-color);
cursor: pointer;
}

.fa-caret-down {
color: var(--primary-color);
cursor: pointer;
}
6 changes: 6 additions & 0 deletions src/components/Header/LanguageButton.module.css.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare const styles: {
readonly wrapper: string;
readonly text: string;
readonly 'fa-caret-down': string;
};
export = styles;
48 changes: 7 additions & 41 deletions src/components/Header/LanguageButton.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,16 @@
import type { FC, MouseEvent } from 'react';
import { FaCaretDown } from 'react-icons/fa';
import styled from 'styled-components';
import { mixins } from '../../styles';

const _Wrapper = styled.div`
@media (max-width: ${mixins.mediaQuerySize.default}) {
padding: 12px 0;
}
box-sizing: border-box;
display: flex;
flex: none;
flex-direction: row;
flex-grow: 0;
gap: 10px;
align-items: center;
justify-content: center;
order: 1;
padding: 12px 20px;
border-radius: 4px;
`;

const _Text = styled.p`
flex: none;
flex-grow: 0;
order: 0;
font-family: Roboto, sans-serif;
font-size: 16px;
font-style: normal;
font-weight: 700;
line-height: 19px;
color: ${mixins.colors.primary};
cursor: pointer;
`;

const faCaretDownStyle = {
color: `${mixins.colors.primary}`,
cursor: 'pointer',
};
import styles from './LanguageButton.module.css';

type Props = {
onClick: (event: MouseEvent<HTMLDivElement>) => void;
};

export const LanguageButton: FC<Props> = ({ onClick }) => (
<_Wrapper onClick={onClick}>
<_Text>Language</_Text>
<FaCaretDown style={faCaretDownStyle} />
</_Wrapper>
// TODO 今はESLintのエラーを無視しているが https://github.com/nekochans/lgtm-cat-ui/issues/279 で修正する
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
<div className={styles.wrapper} onClick={onClick}>
<p className={styles.text}>Language</p>
<FaCaretDown className={styles['fa-caret-down']} />
</div>
);
2 changes: 1 addition & 1 deletion src/components/Header/LanguageMenu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
padding: 0;
}

@media (max-width: var(--media-query-default-size)) {
@media (max-width: 767px) {
.wrapper {
right: 0;
}
Expand Down
1 change: 0 additions & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
--sub-text-color: #8e7e78;
--white-color: #ffffff;
--background-color: #faf9f7;
--media-query-default-size: 767px;
}

.button-base {
Expand Down

0 comments on commit e1c63ba

Please sign in to comment.