From abdf91c691b924b75d71db49fba296da9c8ddcac Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Dec 2018 16:01:53 -0800 Subject: feat: move all @next files to non @next directory --- packages/website/ts/components/text.tsx | 83 +++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 packages/website/ts/components/text.tsx (limited to 'packages/website/ts/components/text.tsx') diff --git a/packages/website/ts/components/text.tsx b/packages/website/ts/components/text.tsx new file mode 100644 index 000000000..9f6ed9e7a --- /dev/null +++ b/packages/website/ts/components/text.tsx @@ -0,0 +1,83 @@ +import * as React from 'react'; +import styled from 'styled-components'; +import { getCSSPadding, PaddingInterface } from 'ts/@next/constants/utilities'; + +interface BaseTextInterface extends PaddingInterface { + size?: 'default' | 'medium' | 'large' | 'small' | number; + isCentered?: boolean; + textAlign?: string; +} + +interface HeadingProps extends BaseTextInterface { + asElement?: 'h1' | 'h2' | 'h3' | 'h4'; + maxWidth?: string; + fontWeight?: string; + isCentered?: boolean; + isFlex?: boolean; + isNoMargin?: boolean; + isMuted?: boolean | number; + marginBottom?: string; + color?: string; +} + +interface ParagraphProps extends BaseTextInterface { + isNoMargin?: boolean; + marginBottom?: string; // maybe we should remove isNoMargin + isMuted?: boolean | number; + fontWeight?: string | number; +} + +const StyledHeading = + styled.h1 < + HeadingProps > + ` + max-width: ${props => props.maxWidth}; + color: ${props => props.color || props.theme.textColor}; + display: ${props => props.isFlex && `inline-flex`}; + align-items: center; + justify-content: ${props => props.isFlex && `space-between`}; + font-size: ${props => + typeof props.size === 'string' ? `var(--${props.size || 'default'}Heading)` : `${props.size}px`}; + line-height: ${props => `var(--${props.size || 'default'}HeadingHeight)`}; + text-align: ${props => props.isCentered && 'center'}; + padding: ${props => props.padding && getCSSPadding(props.padding)}; + margin-left: ${props => props.isCentered && 'auto'}; + margin-right: ${props => props.isCentered && 'auto'}; + margin-bottom: ${props => !props.isNoMargin && (props.marginBottom || '30px')}; + opacity: ${props => (typeof props.isMuted === 'boolean' ? 0.75 : props.isMuted)}; + font-weight: ${props => (props.fontWeight ? props.fontWeight : ['h4'].includes(props.asElement) ? 400 : 300)}; + width: ${props => props.isFlex && `100%`}; +`; + +export const Heading: React.StatelessComponent = props => { + const { asElement = 'h1', children } = props; + const Component = StyledHeading.withComponent(asElement); + + return {children}; +}; + +Heading.defaultProps = { + size: 'default', +}; + +// No need to declare it twice as Styled then rewrap as a stateless comp +// Note: this would be useful to be implemented the same way was "Heading" +// and be more generic. e.g. with a props asElement so we can use it +// for literally anything = +export const Paragraph = + styled.p < + ParagraphProps > + ` + font-size: ${props => `var(--${props.size || 'default'}Paragraph)`}; + font-weight: ${props => props.fontWeight || 300}; + margin-bottom: ${props => !props.isNoMargin && (props.marginBottom || '30px')}; + padding: ${props => props.padding && getCSSPadding(props.padding)}; + color: ${props => props.color || props.theme.paragraphColor}; + opacity: ${props => (typeof props.isMuted === 'boolean' ? 0.75 : props.isMuted)}; + text-align: ${props => (props.textAlign ? props.textAlign : props.isCentered && 'center')}; + line-height: 1.4; +`; + +Paragraph.defaultProps = { + isMuted: true, +}; -- cgit v1.2.3 From a67b34700e48cdf9a54c601af4ec9b9112fe4803 Mon Sep 17 00:00:00 2001 From: fragosti Date: Thu, 20 Dec 2018 16:03:06 -0800 Subject: feat: remove @next directory from all imports --- packages/website/ts/components/text.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/website/ts/components/text.tsx') diff --git a/packages/website/ts/components/text.tsx b/packages/website/ts/components/text.tsx index 9f6ed9e7a..10f272e73 100644 --- a/packages/website/ts/components/text.tsx +++ b/packages/website/ts/components/text.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import styled from 'styled-components'; -import { getCSSPadding, PaddingInterface } from 'ts/@next/constants/utilities'; +import { getCSSPadding, PaddingInterface } from 'ts/constants/utilities'; interface BaseTextInterface extends PaddingInterface { size?: 'default' | 'medium' | 'large' | 'small' | number; -- cgit v1.2.3