made it easier to work with card and main content
converted card and main content card to a styled components
This commit is contained in:
parent
37f33d0f95
commit
a771fb2038
9 changed files with 79 additions and 55 deletions
29
source/src/components/Card.tsx
Normal file
29
source/src/components/Card.tsx
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import styled, { css } from "styled-components"
|
||||||
|
|
||||||
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
|
export const cardCSS = css`
|
||||||
|
margin: auto;
|
||||||
|
background-color: ${(props) =>
|
||||||
|
theming.theme(props.theme.currentTheme, {
|
||||||
|
light: "white",
|
||||||
|
dark: "#2F3136",
|
||||||
|
})};
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: 6px;
|
||||||
|
box-shadow: ${(props) =>
|
||||||
|
theming.theme(props.theme.currentTheme, {
|
||||||
|
light: "0 4px 10px rgb(0 0 0 / 5%), 0 0 1px rgb(0 0 0 / 10%);",
|
||||||
|
dark: "0 4px 10px rgb(0 0 0 / 30%), 0 0 1px rgb(0 0 0 / 30%);",
|
||||||
|
})};
|
||||||
|
|
||||||
|
@media screen and (max-width: ${theming.size.screen_size1}) {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const Card = styled.div`
|
||||||
|
${cardCSS}
|
||||||
|
`
|
||||||
|
|
||||||
|
export default Card
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
|
||||||
|
import MainContent from "./MainContent"
|
||||||
|
|
||||||
import theming from "../styles/theming"
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled(MainContent)`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
@ -93,7 +95,7 @@ const StyledSVG = styled.svg`
|
||||||
|
|
||||||
const Spinner = () => {
|
const Spinner = () => {
|
||||||
return (
|
return (
|
||||||
<StyledContainer className="card main-content">
|
<StyledContainer>
|
||||||
<StyledSVG
|
<StyledSVG
|
||||||
width="37"
|
width="37"
|
||||||
height="48"
|
height="48"
|
||||||
|
|
21
source/src/components/MainContent.tsx
Normal file
21
source/src/components/MainContent.tsx
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import styled, { css } from "styled-components"
|
||||||
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
|
import Card from "./Card"
|
||||||
|
|
||||||
|
export const mainContentCSS = css`
|
||||||
|
margin-top: 3rem;
|
||||||
|
width: 50%;
|
||||||
|
|
||||||
|
@media screen and (max-width: ${theming.size.screen_size1}) {
|
||||||
|
width: auto;
|
||||||
|
margin: 1rem;
|
||||||
|
margin-top: 3rem;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const MainContent = styled(Card)`
|
||||||
|
${mainContentCSS}
|
||||||
|
`
|
||||||
|
|
||||||
|
export default MainContent
|
|
@ -10,12 +10,13 @@ import {
|
||||||
faHourglass,
|
faHourglass,
|
||||||
} from "@fortawesome/free-solid-svg-icons"
|
} from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
import Tag from "../components/Tag"
|
import Tag from "./Tag"
|
||||||
import TagList from "../components/TagList"
|
import TagList from "./TagList"
|
||||||
|
import MainContent from "./MainContent"
|
||||||
|
|
||||||
import theming from "../styles/theming"
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
const StyledPostCard = styled.div`
|
const StyledPostCard = styled(MainContent)`
|
||||||
box-shadow: 0 4px 10px rgb(0 0 0 / 10%);
|
box-shadow: 0 4px 10px rgb(0 0 0 / 10%);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2rem;
|
||||||
|
@ -72,7 +73,6 @@ const PostCard = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<StyledPostCard
|
<StyledPostCard
|
||||||
key={props.postData.url}
|
key={props.postData.url}
|
||||||
className="card main-content"
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(process.env.PUBLIC_URL + props.postData.url)
|
navigate(process.env.PUBLIC_URL + props.postData.url)
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
import { Helmet } from "react-helmet-async"
|
import { Helmet } from "react-helmet-async"
|
||||||
|
|
||||||
|
import MainContent from "../components/MainContent"
|
||||||
|
|
||||||
import theming from "../styles/theming"
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
const StyledNotFound = styled.div`
|
const StyledNotFound = styled(MainContent)`
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
color: ${(props) =>
|
color: ${(props) =>
|
||||||
|
@ -33,7 +35,7 @@ const NotFound = () => {
|
||||||
<meta property="og:description" content="Page does not exist" />
|
<meta property="og:description" content="Page does not exist" />
|
||||||
</Helmet>
|
</Helmet>
|
||||||
|
|
||||||
<StyledNotFound className="card main-content">
|
<StyledNotFound>
|
||||||
<Styled404>404</Styled404>
|
<Styled404>404</Styled404>
|
||||||
<br />
|
<br />
|
||||||
Page was not found :(
|
Page was not found :(
|
||||||
|
|
|
@ -17,10 +17,11 @@ import {
|
||||||
faHourglass,
|
faHourglass,
|
||||||
} from "@fortawesome/free-solid-svg-icons"
|
} from "@fortawesome/free-solid-svg-icons"
|
||||||
|
|
||||||
import Tag from "../components/Tag"
|
import MainContent from "../components/MainContent"
|
||||||
import TagList from "../components/TagList"
|
|
||||||
import NotFound from "./NotFound"
|
|
||||||
import Loading from "../components/Loading"
|
import Loading from "../components/Loading"
|
||||||
|
import TagList from "../components/TagList"
|
||||||
|
import Tag from "../components/Tag"
|
||||||
|
import NotFound from "./NotFound"
|
||||||
|
|
||||||
import theming from "../styles/theming"
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
|
@ -29,6 +30,10 @@ import { useEffect } from "react"
|
||||||
|
|
||||||
const map: Map = _map
|
const map: Map = _map
|
||||||
|
|
||||||
|
const StyledPage = styled(MainContent)`
|
||||||
|
padding-top: 0;
|
||||||
|
`
|
||||||
|
|
||||||
const StyledTitle = styled.h1`
|
const StyledTitle = styled.h1`
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
`
|
`
|
||||||
|
@ -308,7 +313,7 @@ const Page = () => {
|
||||||
/>
|
/>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
|
|
||||||
<div className="card main-content" style={{ paddingTop: 0 }}>
|
<StyledPage>
|
||||||
{isSeries ? (
|
{isSeries ? (
|
||||||
<NextPrevButton
|
<NextPrevButton
|
||||||
prevURL={seriesData?.prev}
|
prevURL={seriesData?.prev}
|
||||||
|
@ -355,7 +360,7 @@ const Page = () => {
|
||||||
__html: fetchedPage.content,
|
__html: fetchedPage.content,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</StyledPage>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,14 @@ import _map from "../data/map.json"
|
||||||
import searchData from "../data/search.json"
|
import searchData from "../data/search.json"
|
||||||
import theming from "../styles/theming"
|
import theming from "../styles/theming"
|
||||||
|
|
||||||
import "react-date-range/dist/styles.css"
|
|
||||||
import "react-date-range/dist/theme/default.css"
|
|
||||||
|
|
||||||
import PostCard from "../components/PostCard"
|
import PostCard from "../components/PostCard"
|
||||||
|
import MainContent from "../components/MainContent"
|
||||||
|
|
||||||
import { Map } from "../types/typings"
|
import { Map } from "../types/typings"
|
||||||
|
|
||||||
|
import "react-date-range/dist/styles.css"
|
||||||
|
import "react-date-range/dist/theme/default.css"
|
||||||
|
|
||||||
const map: Map = _map
|
const map: Map = _map
|
||||||
|
|
||||||
const searchIndex = elasticlunr.Index.load(searchData as never)
|
const searchIndex = elasticlunr.Index.load(searchData as never)
|
||||||
|
@ -36,7 +37,7 @@ interface Query {
|
||||||
query: string
|
query: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledSearch = styled.div`
|
const StyledSearch = styled(MainContent)`
|
||||||
text-align: center;
|
text-align: center;
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ const Search = () => {
|
||||||
<title>pomp | Search</title>
|
<title>pomp | Search</title>
|
||||||
</Helmet>
|
</Helmet>
|
||||||
|
|
||||||
<StyledSearch className="card main-content">
|
<StyledSearch>
|
||||||
<h1>Search</h1>
|
<h1>Search</h1>
|
||||||
|
|
||||||
<StyledSearchContainer>
|
<StyledSearchContainer>
|
||||||
|
|
1
source/src/react-app-env.d.ts
vendored
Normal file
1
source/src/react-app-env.d.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="react-scripts" />
|
|
@ -176,41 +176,6 @@ const whiteLinkCSS = css`
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const cardCSS = css`
|
|
||||||
.card {
|
|
||||||
margin: auto;
|
|
||||||
background-color: ${(props) =>
|
|
||||||
theming.theme(props.theme.currentTheme, {
|
|
||||||
light: "white",
|
|
||||||
dark: "#2F3136",
|
|
||||||
})};
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: 6px;
|
|
||||||
box-shadow: ${(props) =>
|
|
||||||
theming.theme(props.theme.currentTheme, {
|
|
||||||
light: "0 4px 10px rgb(0 0 0 / 5%), 0 0 1px rgb(0 0 0 / 10%);",
|
|
||||||
dark: "0 4px 10px rgb(0 0 0 / 30%), 0 0 1px rgb(0 0 0 / 30%);",
|
|
||||||
})};
|
|
||||||
|
|
||||||
@media screen and (max-width: ${theming.size.screen_size1}) {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const mainContentCSS = css`
|
|
||||||
.main-content {
|
|
||||||
margin-top: 3rem;
|
|
||||||
width: 50%;
|
|
||||||
|
|
||||||
@media screen and (max-width: ${theming.size.screen_size1}) {
|
|
||||||
width: auto;
|
|
||||||
margin: 1rem;
|
|
||||||
margin-top: 3rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const globalStyle = css`
|
const globalStyle = css`
|
||||||
${scrollbarCSS}
|
${scrollbarCSS}
|
||||||
${codeCSS}
|
${codeCSS}
|
||||||
|
@ -218,8 +183,6 @@ const globalStyle = css`
|
||||||
${tableCSS}
|
${tableCSS}
|
||||||
${blockquoteCSS}
|
${blockquoteCSS}
|
||||||
${whiteLinkCSS}
|
${whiteLinkCSS}
|
||||||
${cardCSS}
|
|
||||||
${mainContentCSS}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue