From 2bed9f51d69d4c76f43b2cea2254ec058cc220dd Mon Sep 17 00:00:00 2001 From: ronronscelestes Date: Tue, 7 Sep 2021 16:21:33 +0200 Subject: [PATCH] onboarding compo redone --- .../Admin/Onboarding/StaticLinks/index.js | 82 ----------- .../src/pages/Admin/Onboarding/Wrapper.js | 131 ------------------ .../admin/src/pages/Admin/Onboarding/index.js | 117 +++++++++++++--- .../Admin/Onboarding/tests/index.test.js | 55 ++++++++ 4 files changed, 153 insertions(+), 232 deletions(-) delete mode 100644 packages/core/admin/admin/src/pages/Admin/Onboarding/StaticLinks/index.js delete mode 100644 packages/core/admin/admin/src/pages/Admin/Onboarding/Wrapper.js create mode 100644 packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/StaticLinks/index.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/StaticLinks/index.js deleted file mode 100644 index c99427904c..0000000000 --- a/packages/core/admin/admin/src/pages/Admin/Onboarding/StaticLinks/index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * StaticLinks - * - */ - -import React from 'react'; -import { useIntl } from 'react-intl'; -import styled from 'styled-components'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { Text } from '@strapi/parts/Text'; -import { InjectionZone } from '../../../../shared/components'; - -const StyledLink = styled.a` - display: flex; - width: 100%; - height: 27px; - padding: 0 20px; - color: ${({ theme }) => theme.colors.neutral400}; - text-decoration: none; - span, - svg { - margin: auto 0; - } - svg { - margin-right: 10px; - } - - ${[Text]} { - color: ${({ theme }) => theme.colors.neutral400}; - margin: auto 0; - } - - &:hover { - background: ${({ theme }) => theme.colors.neutral100}; - color: ${({ theme }) => theme.colors.neutral500}; - - ${[Text]} { - color: ${({ theme }) => theme.colors.neutral700}; - } - } - - ${[Text]} { - color: ${({ theme }) => theme.colors.neutral600}; - } -`; - -const StaticLinks = () => { - const { formatMessage } = useIntl(); - const staticLinks = [ - { - icon: 'book', - label: formatMessage({ id: 'app.components.LeftMenuFooter.documentation' }), - destination: 'https://strapi.io/documentation', - }, - { - icon: 'file', - label: formatMessage({ id: 'app.static.links.cheatsheet' }), - destination: 'https://strapi-showcase.s3-us-west-2.amazonaws.com/CheatSheet.pdf', - }, - ]; - - return ( - - ); -}; - -export default StaticLinks; diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/Wrapper.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/Wrapper.js deleted file mode 100644 index c1b4919e4f..0000000000 --- a/packages/core/admin/admin/src/pages/Admin/Onboarding/Wrapper.js +++ /dev/null @@ -1,131 +0,0 @@ -import styled, { keyframes } from 'styled-components'; - -const fadeIn = keyframes` -0% { - width: auto; - height: auto; - opacity: 0; -} - -5% { - opacity: 0; -} - -100% { - opacity: 1; -} -`; -const fadeOut = keyframes` -0% { - opacity: 1; -} - -60% { - opacity: 0; -} - -100% { - opacity: 0; - width: 0; - height: 0; -} -`; - -const Wrapper = styled.div` - max-width: ${({ isOpen }) => (isOpen ? 'initial' : '0px')}; - position: fixed; - right: 15px; - bottom: 15px; - button, - button:focus, - a { - cursor: pointer; - outline: 0; - } - p { - margin-bottom: 0; - } - .videosHeader { - padding: 25px 15px 18px 15px; - p { - display: inline-block; - vertical-align: top; - width: 50%; - font-family: Lato; - font-weight: bold; - font-size: 11px; - color: #5c5f66; - letter-spacing: 0.5px; - text-transform: uppercase; - &:last-of-type { - color: #5a9e06; - text-align: right; - } - } - } - &.visible { - opacity: 1; - z-index: 10; - } - &.hidden { - opacity: 0; - } - .videosContent { - min-width: 320px; - margin-bottom: 10px; - margin-right: 15px; - background-color: white; - box-shadow: 0 2px 4px 0 #e3e9f3; - border-radius: ${({ theme }) => theme.spaces[2]}; - overflow: hidden; - &.shown { - animation: ${fadeIn} 0.5s forwards; - } - &.hide { - min-width: 0; - animation: ${fadeOut} 0.5s forwards; - } - ul { - padding: 0 0 8px 0; - margin-bottom: 0; - list-style: none; - &:last-of-type { - padding: 8px 0 10px 0; - border-top: 1px solid #f6f6f6; - } - } - } - .openBtn { - float: right; - width: 38px; - height: 38px; - button { - width: 100%; - height: 100%; - border-radius: 50%; - color: white; - background: ${({ theme }) => theme.colors.primary600}; - box-shadow: ${({ theme }) => theme.shadows.tableShadow}; - i, - svg { - margin: auto; - } - i:last-of-type, - svg:last-of-type { - display: none; - } - &.active { - i:first-of-type, - svg:first-of-type { - display: none; - } - i:last-of-type, - svg:last-of-type { - display: block; - } - } - } - } -`; - -export default Wrapper; diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js index 2de3454a3f..6b16bd118c 100644 --- a/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js +++ b/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js @@ -1,40 +1,119 @@ import React, { useState } from 'react'; +import styled from 'styled-components'; +import { useIntl } from 'react-intl'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faQuestion, faTimes } from '@fortawesome/free-solid-svg-icons'; -import cn from 'classnames'; +import { Box } from '@strapi/parts/Box'; +import { Text } from '@strapi/parts/Text'; import { useConfigurations } from '../../../hooks'; -import StaticLinks from './StaticLinks'; -import Wrapper from './Wrapper'; + +const Wrapper = styled.button` + position: fixed; + bottom: ${({ theme }) => theme.spaces[2]}; + right: ${({ theme }) => theme.spaces[2]}; + width: ${({ theme }) => theme.spaces[8]}; + height: ${({ theme }) => theme.spaces[8]}; + background: ${({ theme }) => theme.colors.primary600}; + box-shadow: ${({ theme }) => theme.shadows.tableShadow}; + border-radius: 50%; + + svg { + color: white; + } +`; + +const LinksWrapper = styled(Box)` + position: absolute; + bottom: ${({ theme }) => `${theme.spaces[9]}`}; + right: 0; + width: ${200 / 16}rem; +`; + +const StyledLink = styled.a` + display: flex; + align-items: center; + width: 100%; + text-decoration: none; + padding: ${({ theme }) => theme.spaces[2]}; + padding-left: ${({ theme }) => theme.spaces[5]}; + + svg { + color: ${({ theme }) => theme.colors.neutral600}; + margin-right: ${({ theme }) => theme.spaces[2]}; + } + + &:hover { + background: ${({ theme }) => theme.colors.neutral100}; + color: ${({ theme }) => theme.colors.neutral500}; + + svg { + color: ${({ theme }) => theme.colors.neutral700}; + } + + ${[Text]} { + color: ${({ theme }) => theme.colors.neutral700}; + } + } + + ${[Text]} { + color: ${({ theme }) => theme.colors.neutral600}; + } +`; const Onboarding = () => { + const [isOpen, setIsOpen] = useState(false); + const { formatMessage } = useIntl(); const { showTutorials } = useConfigurations(); if (!showTutorials) { return null; } - return ; -}; - -const OnboardingVideos = () => { - const [isOpen, setIsOpen] = useState(false); + const staticLinks = [ + { + icon: 'book', + label: formatMessage({ + id: 'app.components.LeftMenuFooter.documentation', + defaultMessage: 'Documentation', + }), + destination: 'https://strapi.io/documentation', + }, + { + icon: 'file', + label: formatMessage({ id: 'app.static.links.cheatsheet', defaultMessage: 'CheatSheet' }), + destination: 'https://strapi-showcase.s3-us-west-2.amazonaws.com/CheatSheet.pdf', + }, + ]; const handleClick = () => { setIsOpen(prev => !prev); }; return ( - -
- -
-
- -
+ + {!isOpen && } + {isOpen && } + {isOpen && ( + + {staticLinks.map(link => ( + + + {link.label} + + ))} + + )} ); }; diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js new file mode 100644 index 0000000000..97d4e05ea0 --- /dev/null +++ b/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { IntlProvider } from 'react-intl'; +import { ThemeProvider, lightTheme } from '@strapi/parts'; +import Onboarding from '../index'; + +const App = ( + + + + + +); + +describe('Onboarding', () => { + it('renders and matches the snapshot', () => { + const { + container: { firstChild }, + } = render(App); + + expect(firstChild).toMatchInlineSnapshot(` + .c0 { + border: 0; + -webkit-clip: rect(0 0 0 0); + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + } + +
+

+

+

+ `); + }); +});