-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] CSS resets #94
[WIP] CSS resets #94
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,26 @@ import React from 'react' | |
import styled from 'styled-components' | ||
import NanoClamp from 'nanoclamp' | ||
|
||
const Clamp = ({children, className, lines}) => ( | ||
import { backgroundColorReset, sizeReset } from '../../utils/styleResets' | ||
|
||
const Clamp = ({ children, className, lines }) => ( | ||
<NanoClamp className={className} lines={lines} text={children} is='p' /> | ||
) | ||
|
||
const CardText = styled(Clamp)` | ||
&&& { | ||
font-family: inherit; | ||
font-size: inherit; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are this |
||
font-weight: inherit; | ||
color: inherit; | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
text-decoration: none; | ||
text-align: inherit; | ||
direction: inherit; | ||
${backgroundColorReset}; | ||
${sizeReset}; | ||
} | ||
` | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { media, isLarge } from '../../utils' | |
|
||
const HEIGHT = '382px' | ||
|
||
const contrastStyle = ({backgroundColor, color}) => css` | ||
const contrastStyle = ({ backgroundColor, color }) => css` | ||
background-color: ${backgroundColor}; | ||
border-color: ${color}; | ||
transition-property: filter; | ||
|
@@ -26,62 +26,65 @@ const largeStyle = css` | |
|
||
${media.mobile` | ||
height: calc(${HEIGHT} * 7/9); | ||
`} | ||
`}; | ||
` | ||
|
||
const hoverStyle = css` | ||
transition-property: background, border-color; | ||
&:hover { | ||
background: #F5F8FA; | ||
border-color: rgba(136,153,166,.5); | ||
background: #f5f8fa; | ||
border-color: rgba(136, 153, 166, 0.5); | ||
} | ||
` | ||
|
||
const reverseStyle = ({cardSize}) => css` | ||
flex-direction: ${isLarge(cardSize) ? 'column-reverse' : 'row-reverse'} | ||
const reverseStyle = ({ cardSize }) => css` | ||
flex-direction: ${isLarge(cardSize) ? 'column-reverse' : 'row-reverse'}; | ||
` | ||
|
||
const roundStyle = ({round}) => css` | ||
const roundStyle = ({ round }) => css` | ||
border-radius: ${round === true ? `.42857em` : round}; | ||
` | ||
|
||
const style = css` | ||
max-width: 500px; | ||
background-color: #fff; | ||
border-width: 1px; | ||
border-style: solid; | ||
border-color: #E1E8ED; | ||
background: #fff; | ||
border: 1px solid #e1e8ed; | ||
margin: 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks a reset |
||
padding: 0; | ||
outline: none; | ||
overflow: hidden; | ||
color: #181919; | ||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | ||
display: flex; | ||
text-decoration: none; | ||
opacity:1; | ||
opacity: 1; | ||
position: relative; | ||
|
||
transition-duration: .15s; | ||
text-align: left; | ||
direction: ltr; | ||
transition-duration: 0.15s; | ||
transition-timing-function: ease-in-out; | ||
box-sizing: border-box; | ||
|
||
&:active, | ||
&:hover { | ||
outline: 0; | ||
* { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uh, sure? |
||
box-sizing: inherit; | ||
} | ||
|
||
${({loading, contrast}) => !loading && !contrast && hoverStyle} | ||
|
||
${({round}) => round && roundStyle} | ||
|
||
${({cardSize}) => isLarge(cardSize) && largeStyle} | ||
|
||
${({reverse}) => reverse && reverseStyle} | ||
|
||
${({backgroundColor, color, contrast}) => contrast && color && backgroundColor && contrastStyle} | ||
|
||
${({backgroundColor, color, contrast}) => contrast && (!color || !backgroundColor) && hoverStyle} | ||
${({ loading, contrast }) => !loading && !contrast && hoverStyle} ${({ | ||
round | ||
}) => round && roundStyle} ${({ cardSize }) => | ||
isLarge(cardSize) && largeStyle} ${({ reverse }) => | ||
reverse && reverseStyle} ${({ backgroundColor, color, contrast }) => | ||
contrast && color && backgroundColor && contrastStyle} ${({ | ||
backgroundColor, | ||
color, | ||
contrast | ||
}) => contrast && (!color || !backgroundColor) && hoverStyle}; | ||
` | ||
|
||
const CardWrap = ({ is, rel, href, target, ...props }) => { | ||
const el = styled[is]`${style}` | ||
const el = styled[is]` | ||
${style}; | ||
` | ||
const opts = is === 'a' ? { ...props, href, rel, target } : props | ||
return createElement(el, opts) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { css } from 'styled-components' | ||
|
||
export const backgroundColorReset = css` | ||
background-color: inherit; | ||
` | ||
|
||
export const sizeReset = css` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking more in a file that content reset per each component, for example: export const cardDescription = css`
text-decoration: none;
` Then when you load the specific reset style into the component is easy to determinate what style are part of the component and what are part of the reset: // resets
${reset.cardDescription};
// specific styles
font-size: 14px;
flex-grow: 2;
margin: auto 0;
line-height: 18px;
${({cardSize}) => !isLarge(cardSize) && mobileDescriptionStyle}; |
||
width: auto; | ||
height: auto; | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the semicolon necessary? 🤔