-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* テーマを切り替えできるようにする * styleを修正
- Loading branch information
Showing
8 changed files
with
121 additions
and
269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { render, waitFor } from '@testing-library/react' | ||
import { expect } from '@jest/globals' | ||
import { | ||
ThemeToggler, | ||
ThemeTogglerProps, | ||
} from '@/components/Common/ThemeToggler' | ||
import { Mock } from 'ts-mockery' | ||
|
||
describe('<ThemeToggler />', () => { | ||
it('正常に描画される', async () => { | ||
const props = Mock.from<ThemeTogglerProps>({}) | ||
const component = render(<ThemeToggler {...props} />) | ||
await waitFor(() => { | ||
expect(component).toBeTruthy() | ||
}) | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Theme } from '@/resources/types' | ||
import { MaterialIcon } from './MaterialIcon' | ||
import styled from 'styled-components' | ||
|
||
const TogglerDiv = styled.div` | ||
height: 40px; | ||
&:hover { | ||
background-color: rgb(var(--bs-secondary-bg-rgb)); | ||
} | ||
` | ||
|
||
const TogglerA = styled.a` | ||
width: 40px; | ||
height: 40px; | ||
padding: 8px; | ||
display: block; | ||
` | ||
|
||
export type ThemeTogglerProps = { | ||
theme: Theme | ||
toggleTheme: () => void | ||
} | ||
|
||
export const ThemeToggler: React.FC<ThemeTogglerProps> = ({ | ||
theme, | ||
toggleTheme, | ||
}) => { | ||
return ( | ||
<TogglerDiv | ||
role="button" | ||
onClick={toggleTheme} | ||
className="d-flex align-items-center rounded-pill" | ||
> | ||
<TogglerA className="rounded-circle text-body-emphasis"> | ||
{theme === 'light' ? ( | ||
<MaterialIcon name="light_mode" /> | ||
) : ( | ||
<MaterialIcon name="dark_mode" /> | ||
)} | ||
</TogglerA> | ||
</TogglerDiv> | ||
) | ||
} |
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.