Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 97e87eb

Browse files
[#46] ThemeSwitch를 Floating Button으로 변경
1 parent 8482838 commit 97e87eb

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

‎src/components/page-header/index.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Link, StaticQuery, graphql } from 'gatsby';
22
import React from 'react';
33
import Post from '../../models/post';
44
import PostSearch from '../post-search';
5-
import ThemeSwitch from '../theme-switch';
65
import './style.scss';
76

87
function PageHeader({ siteTitle }) {
@@ -43,7 +42,6 @@ function PageHeader({ siteTitle }) {
4342
<PostSearch
4443
posts={data.allMarkdownRemark.edges.map(({ node }) => new Post(node, true))}
4544
/>
46-
<ThemeSwitch />
4745
</div>
4846
</div>
4947
</header>

‎src/components/theme-switch/index.js‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Switch } from '@material-ui/core';
2+
import { IconButton } from '@mui/material';
3+
import DarkModeIcon from '@mui/icons-material/DarkMode';
4+
import LightModeIcon from '@mui/icons-material/LightMode';
35
import { getValueFromLocalStorage, setValueToLocalStorage } from '../../utils/localStorage';
46
import './style.scss';
57

@@ -12,13 +14,15 @@ function ThemeSwitch() {
1214
}, [isDarkMode]);
1315

1416
return (
15-
<Switch
16-
className="dark-mode-switch"
17-
size="medium"
18-
color="default"
19-
checked={isDarkMode}
20-
onChange={() => setIsDarkMode((isDark) => !isDark)}
21-
/>
17+
<div className="dark-mode-button-wrapper">
18+
<IconButton className="dark-mode-button" onClick={() => setIsDarkMode((isDark) => !isDark)}>
19+
{isDarkMode ? (
20+
<LightModeIcon className="dark-mode-icon" fontSize="large" />
21+
) : (
22+
<DarkModeIcon className="dark-mode-icon" fontSize="large" />
23+
)}
24+
</IconButton>
25+
</div>
2226
);
2327
}
2428

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
@use '../../styles/mixins'as *;
22

3-
.dark-mode-switch {
4-
margin-left: 3px;
3+
.dark-mode-button-wrapper {
4+
position: fixed;
5+
display: flex;
6+
justify-content: center;
7+
align-items: center;
8+
bottom: 20px;
9+
right: 20px;
10+
}
511

6-
@include md {
7-
margin-left: 13px;
8-
}
12+
.dark-mode-button {
13+
width: 50px;
14+
height: 50px;
15+
border-radius: 50px;
16+
background-color: #363f47 !important;
17+
cursor: pointer;
18+
box-shadow: 0px 5px 25px rgb(0 0 0 / 12%);
19+
backdrop-filter: blur(30px);
20+
z-index: 3;
21+
}
22+
23+
.dark-mode-icon {
24+
color: white;
925
}

‎src/layout/index.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { useStaticQuery, graphql } from 'gatsby';
33
import PageHeader from '../components/page-header';
44
import PageFooter from '../components/page-footer';
5+
import ThemeSwitch from '../components/theme-switch';
56
import './style.scss';
67

78
const Layout = ({ children }) => {
@@ -30,6 +31,7 @@ const Layout = ({ children }) => {
3031
author={author.name || `Author`}
3132
githubUrl={author.social?.github || `https://www.github.com`}
3233
/>
34+
<ThemeSwitch />
3335
</div>
3436
);
3537
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /