diff --git a/src/OnboardingSPA/components/Animate/stylesheet.scss b/src/OnboardingSPA/components/Animate/stylesheet.scss index 2f187e862..00ce8b300 100644 --- a/src/OnboardingSPA/components/Animate/stylesheet.scss +++ b/src/OnboardingSPA/components/Animate/stylesheet.scss @@ -109,6 +109,32 @@ } } +@-webkit-keyframes spin { + + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes spin { + + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + .animate { &__blank { @@ -141,7 +167,6 @@ @media (prefers-reduced-motion) { animation: none !important; - translation: none !important; } } @@ -150,7 +175,6 @@ @media (prefers-reduced-motion) { animation: none !important; - translation: none !important; } } @@ -159,7 +183,6 @@ @media (prefers-reduced-motion) { animation: none !important; - translation: none !important; } } } diff --git a/src/OnboardingSPA/components/Button/ButtonNext/index.js b/src/OnboardingSPA/components/Button/ButtonNext/index.js new file mode 100644 index 000000000..fdac41e89 --- /dev/null +++ b/src/OnboardingSPA/components/Button/ButtonNext/index.js @@ -0,0 +1,43 @@ +import { useNavigate } from 'react-router-dom'; +import { __ } from '@wordpress/i18n'; +import { useSelect } from '@wordpress/data'; +import { Button } from '@wordpress/components'; +import { Icon, chevronRight } from '@wordpress/icons'; + +import { store as nfdOnboardingStore } from '../../../store'; +import classNames from 'classnames'; + +const ButtonNext = ( { disabled = false } ) => { + const { nextStep } = useSelect( ( select ) => { + return { + nextStep: select( nfdOnboardingStore ).getNextStep(), + }; + } ); + /* [TODO]: some sense of isStepComplete to enable/disable */ + const navigate = useNavigate(); + const navigateNext = () => { + if ( disabled ) { + return; + } + + navigate( nextStep.path, { state: { origin: 'header' } } ); + }; + return ( + + ); +}; + +export default ButtonNext; diff --git a/src/OnboardingSPA/components/Button/ButtonNext/stylesheet.scss b/src/OnboardingSPA/components/Button/ButtonNext/stylesheet.scss new file mode 100644 index 000000000..96d85ed9f --- /dev/null +++ b/src/OnboardingSPA/components/Button/ButtonNext/stylesheet.scss @@ -0,0 +1,21 @@ +.nfd-onboarding-button { + + &--next { + background-color: var(--nfd-onboarding-primary); + color: var(--nfd-onboarding-secondary); + width: 80px; + height: 50px; + font-size: 15px; + border-radius: 8px; + padding: 16px; + + &--disabled { + background-color: rgba(var(--nfd-onboarding-primary-rgb), 0.4); + + &:hover { + cursor: not-allowed; + color: var(--nfd-onboarding-secondary); + } + } + } +} diff --git a/src/OnboardingSPA/components/ImageUploader/index.js b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithIcon/index.js similarity index 93% rename from src/OnboardingSPA/components/ImageUploader/index.js rename to src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithIcon/index.js index 61a28a607..5fcd79058 100644 --- a/src/OnboardingSPA/components/ImageUploader/index.js +++ b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithIcon/index.js @@ -1,14 +1,14 @@ import { __ } from '@wordpress/i18n'; import { memo, useRef, useState } from '@wordpress/element'; -import { ImageUploadLoader } from '../Loaders'; -import { uploadImage } from '../../utils/api/uploader'; +import { ImageUploadLoader } from '../../../Loaders'; +import { uploadImage } from '../../../../utils/api/uploader'; /* * Image Uploader * */ -const ImageUploader = ( { icon, iconSetter } ) => { +const ImageUploaderWithIcon = ( { icon, iconSetter } ) => { const inputRef = useRef( null ); const [ isUploading, setIsUploading ] = useState( false ); const [ onDragActive, setOnDragActive ] = useState( false ); @@ -151,4 +151,4 @@ const ImageUploader = ( { icon, iconSetter } ) => { ); }; -export default memo( ImageUploader ); +export default memo( ImageUploaderWithIcon ); diff --git a/src/OnboardingSPA/components/ImageUploader/stylesheet.scss b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithIcon/stylesheet.scss similarity index 100% rename from src/OnboardingSPA/components/ImageUploader/stylesheet.scss rename to src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithIcon/stylesheet.scss diff --git a/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js new file mode 100644 index 000000000..ed1ae1fc1 --- /dev/null +++ b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js @@ -0,0 +1,168 @@ +import { __ } from '@wordpress/i18n'; + +import { memo, useContext, useRef, useState } from '@wordpress/element'; +import { uploadImage } from '../../../../utils/api/uploader'; +import Spinner from '../../../Loaders/Spinner'; +import { ThemeContext } from '../../../ThemeContextProvider'; +import classNames from 'classnames'; +import { THEME_LIGHT } from '../../../../../constants'; + +const ImageUploaderWithText = ( { image, imageSetter } ) => { + const inputRef = useRef( null ); + const { theme } = useContext( ThemeContext ); + const [ isUploading, setIsUploading ] = useState( false ); + const [ onDragActive, setOnDragActive ] = useState( false ); + + async function updateItem( fileData ) { + if ( fileData ) { + setIsUploading( true ); + const res = await uploadImage( fileData ); + if ( res ) { + const id = res?.body?.id; + const url = res?.body?.source_url; + imageSetter( { + id, + url, + } ); + } + } + + setIsUploading( false ); + } + + const handleClick = () => { + inputRef?.current.click(); + }; + + const handleDragEnter = ( e ) => { + e.preventDefault(); + e.stopPropagation(); + setOnDragActive( true ); + }; + + const handleDragLeave = ( e ) => { + e.preventDefault(); + e.stopPropagation(); + setOnDragActive( false ); + }; + + const handleDragOver = ( e ) => { + e.preventDefault(); + e.stopPropagation(); + setOnDragActive( true ); + }; + + const removeSelectedImage = () => { + imageSetter( { + id: 0, + url: '', + } ); + if ( inputRef?.current?.files.length > 0 ) { + inputRef.current.value = ''; + } + }; + + const imageChange = ( e ) => { + if ( e?.target?.files && e?.target?.files.length > 0 ) { + updateItem( e?.target?.files[ 0 ] ); + } + }; + + const handleDrop = ( e ) => { + e.preventDefault(); + e.stopPropagation(); + setOnDragActive( false ); + if ( e?.dataTransfer?.files && e?.dataTransfer?.files.length > 0 ) { + if ( + e?.dataTransfer?.files[ 0 ]?.type.split( '/' )[ 0 ] === 'image' + ) { + updateItem( e?.dataTransfer?.files[ 0 ] ); + } + } + }; + + return ( +
+ + { __( + 'Drop your logo here, or ', + 'wp-module-onboarding' + ) } + + + +
++ { __( + 'supports .jpg, .png, .gif', + 'wp-module-onboarding' + ) } +
+