728x90
App.tsx
import React from 'react';
import styled, { createGlobalStyle } from "styled-components";
import Router from './Router';
const GlobalStyle = createGlobalStyle`
@import url('https://fonts.googleapis.com/css2?family=Hind&display=swap');
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, menu, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
main, menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, main, menu, nav, section {
display: block;
}
/* HTML5 hidden-attribute fix for newer browsers */
*[hidden] {
display: none;
}
body {
line-height: 1;
}
menu, ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
*{
box-sizing: border-box;
}
body {
font-family: 'Hind', sans-serif;
background-color: ${(props)=> props.theme.bgColor};
color: ${(props)=> props.theme.textColor}
}
a {
text-decoration: none;
}
`;
function App() {
return (
<>
<GlobalStyle />
<Router/>
</>
);
}
export default App;
index.tsx
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { ThemeProvider } from 'styled-components';
import { theme } from './theme';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>
</React.StrictMode>
);
styled.d.ts
import 'styled-components';
declare module 'styled-components' {
export interface DefaultTheme {
textColor: string;
bgColor: string;
accentColor: string;
}
}
theme.ts
import { DefaultTheme } from "styled-components";
export const theme:DefaultTheme = {
bgColor: "#1e272e",
textColor: "#f5f6fa",
accentColor: "#f53b57",
}
728x90
'부트캠프교육중 > react' 카테고리의 다른 글
[React] React query 적용 전 코드 (0) | 2023.08.26 |
---|---|
[React] useRouteMatch, useMatch (0) | 2023.08.25 |
[React] react-router-dom 6.4 (0) | 2023.08.24 |
[React] react memo (0) | 2023.08.24 |
[Recoil] atom, selector (0) | 2023.08.23 |