Skip to content

Commit

Permalink
Design QA fixes:
Browse files Browse the repository at this point in the history
* replace feedback toast with dialog
  • Loading branch information
icaraps committed Sep 23, 2020
1 parent 66b0549 commit cad4b3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 84 deletions.
1 change: 0 additions & 1 deletion packages/gatsby-theme-parliament/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"@spectrum-css/popover": "^3.0.0-beta.3",
"@spectrum-css/sidenav": "^3.0.0-beta.2",
"@spectrum-css/tabs": "^3.0.0-beta.3",
"@spectrum-css/toast": "^3.0.0-beta.3",
"@spectrum-css/tooltip": "^3.0.0-beta.2",
"@spectrum-css/typography": "^2.1.3",
"@spectrum-css/vars": "^2.3.0",
Expand Down
109 changes: 31 additions & 78 deletions packages/gatsby-theme-parliament/src/components/Feedback/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,87 +10,40 @@
* governing permissions and limitations under the License.
*/

import React, { useState } from 'react';
import React from 'react';
import { css } from '@emotion/core';
import classNames from 'classnames';
import { Flex } from '@adobe/react-spectrum';
import { View } from '@adobe/react-spectrum';
import { Button } from '@adobe/react-spectrum';
import '@spectrum-css/toast';
import { DialogTrigger } from '@adobe/react-spectrum';
import { AlertDialog } from '@adobe/react-spectrum';

const onFeedback = (setIsOpen) => {
setIsOpen(true);
setTimeout(() => {
setIsOpen(false);
}, 3000);
};
const FeedbackButton = ({ variant }) => (
<DialogTrigger>
<Button UNSAFE_className={`feedback-${variant.toLowerCase()}`} variant="primary">
{variant}
</Button>
<AlertDialog title="Was this helpful ?" primaryActionLabel="Close">
Thank you for providing your feedback.
</AlertDialog>
</DialogTrigger>
);

export const Feedback = () => {
const [isOpen, setIsOpen] = useState(false);

return (
<>
<Flex alignItems="center">
<span
css={css`
padding-right: var(--spectrum-global-dimension-size-200);
`}>
Was this helpful ?
</span>
<Flex>
<View marginEnd="size-200">
<Button
UNSAFE_className="feedback-yes"
variant="primary"
onPress={() => {
onFeedback(setIsOpen);
}}>
Yes
</Button>
</View>
<View>
<Button
UNSAFE_className="feedback-no"
variant="primary"
onPress={() => {
onFeedback(setIsOpen);
}}>
No
</Button>
</View>
</Flex>
</Flex>
<div
className={classNames('spectrum-Toast', 'spectrum-Toast--positive', { 'is-open': isOpen })}
role="alert"
aria-live="polite"
css={css`
pointer-events: none;
position: fixed;
left: 50%;
bottom: var(--spectrum-global-dimension-size-200);
z-index: 10;
visibility: hidden;
opacity: 0;
transform: translate3d(-50%, 0, 0);
transition: transform var(--spectrum-global-animation-duration-100)
var(--spectrum-global-animation-ease-in-out),
opacity var(--spectrum-global-animation-duration-100) var(--spectrum-global-animation-ease-in-out),
visibility var(--spectrum-global-animation-duration-0) var(--spectrum-global-animation-linear)
var(--spectrum-global-animation-duration-100);
&.is-open {
pointer-events: auto;
visibility: visible;
opacity: 1;
transition-delay: var(--spectrum-global-animation-duration-0);
transform: translate3d(-50%, calc(-1 * var(--spectrum-global-dimension-size-200)), 0);
}
`}>
<div className="spectrum-Toast-body">
<div className="spectrum-Toast-content">Thank you for your feedback.</div>
</div>
</div>
</>
);
};
export const Feedback = () => (
<Flex alignItems="center">
<span
css={css`
padding-right: var(--spectrum-global-dimension-size-200);
`}>
Was this helpful ?
</span>
<Flex>
<View marginEnd="size-200">
<FeedbackButton variant="Yes" />
</View>
<View>
<FeedbackButton variant="No" />
</View>
</Flex>
</Flex>
);
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2909,11 +2909,6 @@
resolved "https://registry.yarnpkg.com/@spectrum-css/textfield/-/textfield-3.0.0-beta.3.tgz#251763260fedd38e256c8a225809b0ecdc70f68f"
integrity sha512-ihTZKLfnUxBnlSGRH4xdSMwd23EkpunC69uUvVB2LGGw1QAcmUcBNdS9xz7PPSWFw4qkCRXzVVX9tLC/2fQFbQ==

"@spectrum-css/toast@^3.0.0-beta.3":
version "3.0.0-beta.3"
resolved "https://registry.yarnpkg.com/@spectrum-css/toast/-/toast-3.0.0-beta.3.tgz#98eb1320062e299cf5a96fe1c59357073fbee6f4"
integrity sha512-W0akUneCrda9Gad12ehOUeOQEYD4ND/S3JAEFKaQyO/4TKK2+70tEBN50w+2cvvvSry6JgSWgRTiU4a/EGbMZg==

"@spectrum-css/tooltip@^3.0.0-beta.2":
version "3.0.0-beta.2"
resolved "https://registry.yarnpkg.com/@spectrum-css/tooltip/-/tooltip-3.0.0-beta.2.tgz#b30538c05eb8edc080e4ab53538ef59bb6a60bc7"
Expand Down

0 comments on commit cad4b3d

Please sign in to comment.