Skip to content

Commit

Permalink
Merge branch 'master' into progress-indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimesque committed Feb 8, 2019
2 parents 53d915f + 333008d commit 12ce359
Show file tree
Hide file tree
Showing 20 changed files with 459 additions and 210 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ unclear-type=warn
unsafe-getters-setters=error

[version]
0.91.0
0.92.1
30 changes: 11 additions & 19 deletions components/Button/CopyLinkButton.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// @flow
// $FlowIssue
import React, { useState } from 'react';
import dynamic from 'next/dynamic';
import * as Styled from './style';
import { CopyLinkButton as StyledCopyLinkButton } from './style';
import Icon from '../Icon';
import type { ButtonProps } from './types';

const Clipboard = dynamic(() => import('react-clipboard.js'), {
ssr: false,
loading: () => null,
});

type CopyLinkProps = {
...$Exact<ButtonProps>,
text: string,
Expand All @@ -26,20 +20,18 @@ export default function CopyLinkButton(props: CopyLinkProps) {
};

return (
<Clipboard
style={{ background: 'none' }}
<StyledCopyLinkButton
data-clipboard-text={text}
onSuccess={onClick}
component="a"
component="button"
data-cy="copy-link-button"
isClicked={isClicked}
aria-label="Copy the website’s address to your clipboard."
type="button"
{...props}
>
<Styled.CopyLinkButton
data-cy="copy-link-button"
isClicked={isClicked}
{...props}
>
<Icon glyph="link" size={24} />
{isClicked ? 'Copied!' : children}
</Styled.CopyLinkButton>
</Clipboard>
<Icon glyph="link" size={24} />
<span>{isClicked ? 'Copied!' : children}</span>
</StyledCopyLinkButton>
);
}
44 changes: 28 additions & 16 deletions components/Button/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import styled, { css } from 'styled-components';
import { hexa, tint } from '../globals';
import type { ButtonSize } from './types';
import { theme } from '../theme';
import dynamic from 'next/dynamic';

const Clipboard = dynamic(() => import('react-clipboard.js'), {
ssr: false,
loading: () => null,
});

const getPadding = (size: ButtonSize) => {
switch (size) {
Expand Down Expand Up @@ -32,7 +38,7 @@ const getFontSize = (size: ButtonSize) => {
}
};

const base = css`
export const base = css`
-webkit-appearance: none;
display: flex;
flex: none;
Expand All @@ -58,11 +64,15 @@ const base = css`
cursor: not-allowed;
}
&:hover {
&:hover, &:active, &:focus {
transition: all 0.2s ease-in-out;
box-shadow: ${props =>
props.disabled ? 'none' : `${theme.shadows.button}`};
}
&:active, &:focus {
box-shadow: 0 0 0 1px ${theme.bg.default},
0 0 0 3px ${props => hexa(props.theme.text.tertiary, 0.5)};
}
`;

export const Button = styled.button`
Expand Down Expand Up @@ -126,7 +136,7 @@ export const PrimaryButton = styled.button`
&:focus {
box-shadow: 0 0 0 1px ${props =>
props.theme.bg.default}, 0 0 0 3px ${props =>
hexa(props.theme.brand.alt, 0.16)};
hexa(props.theme.brand.alt, 0.5)};
}
`;

Expand All @@ -137,15 +147,15 @@ export const GhostButton = styled.button`
background-color: transparent;
background-image: none;
&:hover {
background: ${props => tint(props.theme.bg.wash, -3)};
&:hover, &:active, &:focus {
background: ${props => tint(props.theme.bg.wash, -8)};
color: ${theme.text.default};
box-shadow: none;
}
&:focus {
&:active, &:focus {
box-shadow: 0 0 0 1px ${theme.bg.default},
0 0 0 3px ${props => hexa(props.theme.text.tertiary, 0.08)};
0 0 0 3px ${props => hexa(props.theme.text.tertiary, 0.25)};
}
`;

Expand Down Expand Up @@ -220,12 +230,12 @@ export const ButtonSegmentRow = styled.div`
${PrimaryButton} {
&:focus {
box-shadow: 0 0 0 1px ${theme.bg.default},
0 0 0 3px ${props => hexa(props.theme.brand.alt, 0.16)};
0 0 0 3px ${props => hexa(props.theme.brand.alt, 0.5)};
}
}
`;

export const FacebookButton = styled.button`
export const FacebookButton = styled.a`
${base}
border: 1px solid ${theme.social.facebook};
color: ${theme.bg.default};
Expand Down Expand Up @@ -262,11 +272,11 @@ export const FacebookButton = styled.button`
&:focus {
box-shadow: 0 0 0 1px ${props =>
props.theme.bg.default}, 0 0 0 3px ${props =>
hexa(props.theme.social.facebook, 0.16)};
hexa(props.theme.social.facebook, 0.5)};
}
`;

export const TwitterButton = styled.button`
export const TwitterButton = styled.a`
${base}
border: 1px solid ${theme.social.twitter};
color: ${theme.bg.default};
Expand Down Expand Up @@ -303,12 +313,13 @@ export const TwitterButton = styled.button`
&:focus {
box-shadow: 0 0 0 1px ${props =>
props.theme.bg.default}, 0 0 0 3px ${props =>
hexa(props.theme.social.twitter, 0.16)};
hexa(props.theme.social.twitter, 0.5)};
}
`;

export const CopyLinkButton = styled.button`
export const CopyLinkButton = styled(Clipboard)`
${base}
transition: all ${theme.animations.default};
border: 1px solid ${props =>
props.isClicked
? tint(props.theme.success.default, -10)
Expand Down Expand Up @@ -356,8 +367,9 @@ export const CopyLinkButton = styled.button`
&:focus {
box-shadow: 0 0 0 1px ${props =>
props.theme.bg.default}, 0 0 0 3px ${props =>
props.isClicked
? hexa(props.theme.success.default, 0.16)
: props.theme.border.default};
props.isClicked
? hexa(props.theme.success.default, 0.5)
: props.theme.border.default};
}
`;

6 changes: 3 additions & 3 deletions components/ChecklistItem/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const AppRow = ({ app }: Props) => {
};

return (
<AppRowContainer href={app.url} target="_blank" rel="noopener noreferrer">
<AppMeta>
<AppRowContainer>
<AppMeta href={app.url} target="_blank" rel="noopener noreferrer" title={`go to: ${app.name}`}>
{app.image && <AppIcon alt={app.name} src={app.image} />}
<AppName>{app.name}</AppName>
</AppMeta>
Expand All @@ -49,4 +49,4 @@ export const AppRow = ({ app }: Props) => {
{app.offer && <Offer offer={app.offer} />}
</AppRowContainer>
);
};
};
57 changes: 44 additions & 13 deletions components/ChecklistItem/Apps.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,74 @@
// @flow
// $FlowIssue
import React, { useState } from 'react';
import { AppsContainer, SectionHeading, ExpandContainer } from './style';
import React, { useState, useRef } from 'react';
import { AppsContainer, SectionHeading, ExpandContainer, ExpandContent } from './style';
import { Button } from '../Button';
import type { ChecklistResource } from '../../types';
import { AppRow } from './App';

type Props = {
resource: ChecklistResource,
handleAppsExpand: Function,
};

export const Apps = ({ resource }: Props) => {
export const Apps = ({ resource, handleAppsExpand }: Props) => {
const [overflowExpanded, setOverflowExpanded] = useState(false);
const [contentHeight, setcontentHeight] = useState(2000);

const expandContentContainer = useRef(null);

function handleExpand() {
let expandContentHeight =
expandContentContainer.current
? expandContentContainer.current.scrollHeight
: contentHeight;

setcontentHeight(expandContentHeight)
setOverflowExpanded(!overflowExpanded)

handleAppsExpand(overflowExpanded ? -expandContentHeight : expandContentHeight);
}

if (!resource.apps) return null;

let appList = resource.apps;
let overflowAppList;
if (appList.length > 3) {
if (appList && appList.length > 3) {
overflowAppList = appList.slice(3, appList.length);
appList = appList.slice(0, 3);
}

return (
<AppsContainer overflowExpanded={overflowExpanded}>
<SectionHeading>Apps</SectionHeading>
{appList.map(app => (
{appList && appList.map(app => (
<AppRow key={app.name} app={app} />
))}

{overflowAppList && !overflowExpanded && (
<ExpandContainer onClick={() => setOverflowExpanded(true)}>
<Button>Show more choices</Button>
</ExpandContainer>
{overflowAppList && (
<React.Fragment>
<ExpandContent
id={`apps_${resource.id}`}
role="region"
tabindex="-1"
ref={expandContentContainer}
style={{ '--maxHeight': `${contentHeight}px` }}
aria-hidden={!overflowExpanded}
>
{overflowAppList.map(app => <AppRow key={app.name} app={app} />)}
</ExpandContent>

<ExpandContainer
onClick={handleExpand}
role="button"
aria-expanded={overflowExpanded}
aria-controls={`apps_${resource.id}`}
>
<Button type="button">Show {overflowExpanded ? "less" : "more"} choices</Button>
</ExpandContainer>
</React.Fragment>
)}

{overflowAppList &&
overflowExpanded &&
overflowAppList.map(app => <AppRow key={app.name} app={app} />)}
</AppsContainer>
);
};

10 changes: 7 additions & 3 deletions components/ChecklistItem/Heading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from 'react';
import { Title, Description, Uncollapse } from './style';
import { Title, Uncollapse } from './style';
import type { ChecklistResource } from '../../types';

type Props = {
Expand All @@ -13,10 +13,14 @@ export const Heading = ({ resource, isCollapsed, handleCollapse }: Props) => (
<React.Fragment>
<Title>
{resource.title}
<Uncollapse onClick={handleCollapse}>
<Uncollapse
onClick={handleCollapse}
aria-controls={`content_${resource.id}`}
aria-expanded={!isCollapsed}
type="button"
>
{isCollapsed ? 'Show details' : 'Hide details'}
</Uncollapse>
</Title>
{!isCollapsed && <Description source={resource.description} />}
</React.Fragment>
);
Loading

0 comments on commit 12ce359

Please sign in to comment.