-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract specific components to be shared between other components
- Loading branch information
1 parent
427ef4f
commit df52f12
Showing
8 changed files
with
200 additions
and
8 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
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,29 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import styled from "styled-components"; | ||
|
||
/** | ||
* A configurable and responsive grid for card components. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.8.0 | ||
*/ | ||
const Grid = styled.div` | ||
display: grid; | ||
grid-gap: 4em; | ||
${({ theme }) => theme.media.tabletLandscape` | ||
grid-template-columns: repeat(2, 1fr); | ||
${({ isExtended }) => isExtended && "grid-template-rows: repeat(2, auto)"}; | ||
`}; | ||
`; | ||
|
||
export default Grid; |
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ import { cardIconPropTypes } from "./propTypes"; | |
* @author Sven Greb <[email protected]> | ||
* @since 0.8.0 | ||
*/ | ||
const CardItemIcon = ({ accentColor, iconComponent: SvgIcon, svgType, ...passProps }) => { | ||
const CardItemIcon = ({ accentColor, iconComponent: SvgIcon, iconOutlined, svgType, ...passProps }) => { | ||
const Icon = styled(SvgIcon)` | ||
width: 1.8em; | ||
${svgType === "stroke" ? `stroke: ${accentColor}` : `fill: ${accentColor}`}; | ||
|
@@ -28,7 +28,7 @@ const CardItemIcon = ({ accentColor, iconComponent: SvgIcon, svgType, ...passPro | |
margin-right: 1em; | ||
`}; | ||
`; | ||
return <Icon {...passProps} />; | ||
return <Icon outlined={iconOutlined} {...passProps} />; | ||
}; | ||
|
||
CardItemIcon.propTypes = cardIconPropTypes; | ||
|
87 changes: 87 additions & 0 deletions
87
src/components/organisms/page/docs/shared/ContentsCard.jsx
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,87 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
|
||
import { A, H3, P } from "atoms/core/html-elements"; | ||
|
||
import ArrowIcon from "./ArrowIcon"; | ||
import Card from "./Card"; | ||
import Icon from "./CardIcon"; | ||
import Topic from "./CardItem"; | ||
import TopicContent from "./CardItemContent"; | ||
import TopicIcon from "./CardItemIcon"; | ||
import Topics from "./CardItems"; | ||
import TopicTag from "./CardItemTag"; | ||
import TopicTitle from "./CardItemTitle"; | ||
import { cardBasePropTypes } from "./propTypes"; | ||
|
||
/** | ||
* A card component that renders information about a docs category and its topics. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.8.0 | ||
*/ | ||
const ContentsCard = ({ accentColor, children, topics, logoComponent: SvgLogo, svgType, title, ...passProps }) => { | ||
const renderedTopics = topics.map( | ||
({ url, title: topicTitle, iconComponent: SvgIcon, iconOutlined, svgType: topicIconSvgType }) => ( | ||
<Topic key={topicTitle} as={url && A} href={url} inProgress={!url}> | ||
<TopicContent> | ||
<TopicIcon | ||
accentColor={accentColor} | ||
iconComponent={SvgIcon} | ||
outlined={iconOutlined} | ||
svgType={topicIconSvgType} | ||
/> | ||
<TopicTitle color={accentColor} inProgress={!url}> | ||
{topicTitle} | ||
</TopicTitle> | ||
</TopicContent> | ||
{!url ? <TopicTag accentColor={accentColor}>In Progress</TopicTag> : <ArrowIcon />} | ||
</Topic> | ||
) | ||
); | ||
return ( | ||
<Card {...passProps}> | ||
<Icon accentColor={accentColor} iconComponent={SvgLogo} svgType={svgType} /> | ||
<div> | ||
<H3>{title}</H3> | ||
<P>{children}</P> | ||
</div> | ||
<Topics>{renderedTopics}</Topics> | ||
</Card> | ||
); | ||
}; | ||
|
||
ContentsCard.propTypes = { | ||
...cardBasePropTypes, | ||
accentColor: PropTypes.string.isRequired, | ||
children: PropTypes.node.isRequired, | ||
svgType: PropTypes.string, | ||
topics: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
iconComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func, PropTypes.node]).isRequired, | ||
iconOutlined: PropTypes.bool, | ||
svgType: PropTypes.string, | ||
title: PropTypes.string, | ||
url: PropTypes.string | ||
}) | ||
).isRequired | ||
}; | ||
|
||
ContentsCard.defaultProps = { | ||
svgType: "fill", | ||
topics: { | ||
iconOutlined: false | ||
} | ||
}; | ||
|
||
export default ContentsCard; |
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,38 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import styled from "styled-components"; | ||
|
||
import { H1 } from "atoms/core/html-elements"; | ||
import { media, motion, ms } from "styles/theme"; | ||
|
||
/** | ||
* A component that represents the large headline of a documentation page. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.8.0 | ||
*/ | ||
const Headline = styled(H1)` | ||
font-weight: bold; | ||
margin-bottom: 0.8em; | ||
font-size: ${ms(6)}; | ||
transition: color ${motion.speed.duration.transition.base.themeModeSwitch}ms ease-in-out; | ||
text-align: center; | ||
${media.tabletLandscape` | ||
font-size: ${ms(7)}; | ||
`}; | ||
${media.desktop` | ||
font-size: ${ms(8)}; | ||
`}; | ||
`; | ||
|
||
export default Headline; |
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,30 @@ | ||
/* | ||
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]> | ||
* Copyright (C) 2018-present Sven Greb <[email protected]> | ||
* | ||
* Project: Nord Docs | ||
* Repository: https://github.com/arcticicestudio/nord-docs | ||
* License: MIT | ||
*/ | ||
|
||
import styled from "styled-components"; | ||
|
||
import { P } from "atoms/core/html-elements"; | ||
import { motion, ms } from "styles/theme"; | ||
|
||
/** | ||
* A component that represents the subline of a documentation page headline. | ||
* | ||
* @author Arctic Ice Studio <[email protected]> | ||
* @author Sven Greb <[email protected]> | ||
* @since 0.8.0 | ||
*/ | ||
const Subline = styled(P)` | ||
font-size: ${ms(2)}; | ||
transition: color ${motion.speed.duration.transition.base.themeModeSwitch}ms ease-in-out; | ||
max-width: 65%; | ||
margin: 0 auto; | ||
text-align: center; | ||
`; | ||
|
||
export default Subline; |
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