Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputs figma #857

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/components/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,27 @@ const Editor = (props: EditorProps) => {

return (
<LexicalComposer initialConfig={settings}>
<Box className='editor-container' bg={'text_area.bg_light'} _dark={{ bgColor: 'text_area.bg_dark' }}>
<Box
className='editor-container'
bg={'text_area.bg_light'}
_dark={{
bgColor: 'text_area.bg_dark',
borderColor: '#4A5568 !important',
gerouvi marked this conversation as resolved.
Show resolved Hide resolved

'.editor-placeholder': {
color: 'rgba(255, 255, 255, 0.24)',
},
gerouvi marked this conversation as resolved.
Show resolved Hide resolved

'&:hover': {
gerouvi marked this conversation as resolved.
Show resolved Hide resolved
outline: '1px solid rgba(255, 255, 255, 0.24)',
},
'&:focus-within': {
borderColor: 'transparent',
outline: '2px solid',
outlineColor: 'input.outline.dark !important',
gerouvi marked this conversation as resolved.
Show resolved Hide resolved
},
}}
>
<ToolbarPlugin setIsLinkEditMode={setIsLinkEditMode} />
<div className='editor-inner'>
<RichTextPlugin
Expand Down
11 changes: 5 additions & 6 deletions src/components/Editor/styles.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
.editor-container {
border-radius: 0.75rem;
border-radius: 8px;
position: relative;
line-height: 20px;
font-weight: 400;
text-align: left;
border: 0.1px solid #e2e8f0;
border: 1px solid #e2e8f0;
margin-bottom: 10px;
overflow: hidden;
}

.editor-container:hover {
border-color: transparent;
outline-offset: '0px';
outline: '.1px solid';
outline: 2px solid #cbd5e0;
outline: 1px solid #cbd5e0;
}

.editor-container:focus-within {
Expand All @@ -28,7 +27,7 @@
.editor-input {
min-height: 150px;
resize: none;
font-size: 15px;
font-size: 16px;
caret-color: rgb(5, 5, 5);
position: relative;
tab-size: 1;
Expand All @@ -44,7 +43,7 @@
text-overflow: ellipsis;
top: 15px;
left: 16px;
font-size: 15px;
font-size: 16px;
user-select: none;
display: inline-block;
pointer-events: none;
Expand Down
16 changes: 3 additions & 13 deletions src/components/Layout/InputBasic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,11 @@ import { useTranslation } from 'react-i18next'
export interface InputBasicProps extends InputProps {
formValue: string
label: string
placeholder?: string
type?: string
required?: boolean
validation?: any
messageError?: string
}
const InputBasic = ({
formValue,
label,
placeholder,
type = 'text',
required = false,
validation = {},
...props
}: InputBasicProps) => {
const InputBasic = ({ formValue, label, required = false, validation = {}, ...props }: InputBasicProps) => {
const { t } = useTranslation()
const {
register,
Expand All @@ -35,8 +25,8 @@ const InputBasic = ({

return (
<FormControl isInvalid={!!errors[formValue]} isRequired={required}>
{label && <FormLabel variant='process-create-title-sm'>{label}</FormLabel>}
<Input {...register(formValue, validationRules)} type={type} placeholder={placeholder} {...props} />
{label && <FormLabel>{label}</FormLabel>}
<Input {...register(formValue, validationRules)} {...props} />
<FormErrorMessage mt={2}>{errorMessage || 'Error performing the operation'}</FormErrorMessage>
</FormControl>
)
Expand Down
61 changes: 61 additions & 0 deletions src/components/Layout/UpLoaderCustom.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Uploader" is a single word (so it should be UploaderCustom.tsx.

Edit: Actually, why call it Custom??? There's no need at all, this is the only component that would be named Uploader in the entire project, if I'm not wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will investigate since it doesn't recognize the changes from uppercase to lowercase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried using the terminal..?

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Box, Flex, Icon, Text } from '@chakra-ui/react'
import { DropzoneInputProps, DropzoneRootProps } from 'react-dropzone/.'
import { Trans, useTranslation } from 'react-i18next'
import { FiUploadCloud } from 'react-icons/fi'

const UpLoaderCustom = ({
getRootProps,
getInputProps,
isDragActive,
}: {
getRootProps: <T extends DropzoneRootProps>(props?: T) => T
getInputProps: <T extends DropzoneInputProps>(props?: T) => T
isDragActive: boolean
}) => {
const { t } = useTranslation()

return (
<Flex
flexDirection='column'
justifyContent='center'
alignItems='center'
gap={5}
p={10}
border={'1px solid'}
borderColor={isDragActive ? 'input.drag_and_drop.border_active' : 'input.drag_and_drop.border'}
cursor='pointer'
borderRadius={12}
{...getRootProps()}
>
<input {...getInputProps()} />
<Flex
justifyContent={'center'}
alignItems={'center'}
border='1px solid'
borderColor={'input.drag_and_drop.border'}
borderRadius='lg'
p={2}
>
<Icon as={FiUploadCloud} boxSize={10} color='process_create.spreadsheet.file' />
</Flex>
<Box>
{isDragActive ? (
<Text textAlign='center' color='process_create.description'>
{t('uploaderCustom.drop_here')}
</Text>
) : (
<Trans
i18nKey='uploader.click_or_drag_and_drop'
components={{
click: <Text as='span' textAlign='center' color='input.drag_and_drop.text' />,
drag: <Text as='span' textAlign='center' />,
formats: <Text textAlign='center' fontSize='sm' color='process_create.description' />,
}}
/>
)}
</Box>
</Flex>
)
}

export default UpLoaderCustom
23 changes: 2 additions & 21 deletions src/components/ProcessCreate/Census/Spreadsheet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Box,
Button,
Card,
CardBody,
Expand All @@ -20,7 +19,7 @@ import { Controller, useFormContext } from 'react-hook-form'
import { Trans, useTranslation } from 'react-i18next'
import { BiCheckDouble, BiDownload } from 'react-icons/bi'
import { PiWarningCircleLight } from 'react-icons/pi'
import { RiFileExcel2Line } from 'react-icons/ri'
import UpLoaderCustom from '~components/Layout/UpLoaderCustom'
import { CensusSpreadsheetManager } from './CensusSpreadsheetManager'
import { CsvGenerator } from './generator'
import { CsvPreview } from './Preview'
Expand Down Expand Up @@ -166,25 +165,7 @@ export const CensusCsvManager = () => {
isInvalid={!!errors?.spreadsheet}
display={manager?.data.length ? 'none' : 'block'}
>
<Card variant='drag-and-drop'>
<input {...getInputProps()} />
<Icon as={RiFileExcel2Line} boxSize={20} color='process_create.spreadsheet.file' />
<Box>
{isDragActive ? (
<Text textAlign='center' color='process_create.description'>
{t('uploader.drop_here')}
</Text>
) : (
<Trans
i18nKey='uploader.click_or_drag_and_drop'
components={{
p1: <Text textAlign='center' color='process_create.description' />,
p2: <Text textAlign='center' fontSize='sm' color='process_create.description' />,
}}
/>
)}
</Box>
</Card>
<UpLoaderCustom getInputProps={getInputProps} getRootProps={getRootProps} isDragActive={isDragActive} />
<FormErrorMessage display='flex' justifyContent='center'>
{errors?.spreadsheet?.message?.toString()}
</FormErrorMessage>
Expand Down
33 changes: 2 additions & 31 deletions src/components/ProcessCreate/Census/Web3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useDropzone } from 'react-dropzone'
import { Controller, useFieldArray, useFormContext } from 'react-hook-form'
import { Trans, useTranslation } from 'react-i18next'
import { BiCheckDouble } from 'react-icons/bi'
import { RiFileExcel2Line } from 'react-icons/ri'
import UpLoaderCustom from '~components/Layout/UpLoaderCustom'
import { addressTextOverflow, fieldMapErrorMessage, isInvalidFieldMap } from '~constants'
import { Web3CensusSpreadsheetManager } from './Spreadsheet/Web3CensusSpreadsheetManager'

Expand Down Expand Up @@ -245,36 +245,7 @@ export const CensusWeb3Addresses = () => {
)}
/>
<FormControl isInvalid={!!fileErr}>
<Flex
flexDirection='column'
justifyContent='center'
alignItems='center'
gap={5}
p={10}
border='1px dotted'
borderColor='process_create.census.drag_and_drop_border'
bgColor='process_create.bg'
cursor='pointer'
{...getRootProps()}
>
<input {...getInputProps()} />
<Icon as={RiFileExcel2Line} boxSize={20} color='process_create.spreadsheet.file' />
<Box>
{isDragActive ? (
<Text textAlign='center' color='process_create.description'>
{t('uploader.drop_here')}
</Text>
) : (
<Trans
i18nKey='uploader.click_or_drag_and_drop'
components={{
p1: <Text textAlign='center' color='process_create.description' />,
p2: <Text textAlign='center' fontSize='sm' color='process_create.description' />,
}}
/>
)}
</Box>
</Flex>
<UpLoaderCustom getInputProps={getInputProps} getRootProps={getRootProps} isDragActive={isDragActive} />
<FormErrorMessage>{fileErr}</FormErrorMessage>
</FormControl>
</Flex>
Expand Down
27 changes: 17 additions & 10 deletions src/components/ProcessCreate/Census/select-components.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChevronDownIcon, SearchIcon } from '@chakra-ui/icons'
import { CheckIcon, ChevronDownIcon, SearchIcon } from '@chakra-ui/icons'
import { Avatar, Flex, Link, Text } from '@chakra-ui/react'
import { getNetwork } from '@ethersproject/providers'
import {
chakraComponents,
DropdownIndicatorProps,
Expand All @@ -8,13 +9,12 @@ import {
OptionProps,
SingleValueProps,
} from 'chakra-react-select'
import { useEffect, useState } from 'react'
import { BsImage } from 'react-icons/bs'
import { FaEthereum } from 'react-icons/fa'
import { FaPeopleGroup } from 'react-icons/fa6'
import ethIcon from '/assets/eth.jpg'
import polygonIcon from '/assets/polygon-matic.jpg'
import { useEffect, useState } from 'react'
import { getNetwork } from '@ethersproject/providers'

const SingleValueToken = (props: SingleValueProps<any, false, GroupBase<any>>) => {
const {
Expand Down Expand Up @@ -55,6 +55,7 @@ const OptionToken = (props: OptionProps<any, false, GroupBase<any>>) => {
const {
children,
data: { type: groupType, name, iconURI, ID, chainID },
isSelected,
} = props
if (groupType === 'request') {
return (
Expand All @@ -72,10 +73,12 @@ const OptionToken = (props: OptionProps<any, false, GroupBase<any>>) => {
} else {
return (
<chakraComponents.Option {...props}>
<Flex alignItems='center' gap={2}>
<CryptoAvatar name={name} icon={iconURI} id={ID} chainId={chainID} />

<Text>{children}</Text>
<Flex justifyContent={'space-between'} alignItems={'center'} w='full'>
<Flex gap={2} color='black'>
<CryptoAvatar name={name} icon={iconURI} id={ID} chainId={chainID} />
<Text>{children}</Text>
</Flex>
{isSelected && <CheckIcon color='input.dropdown.check_icon' ml='auto' />}
elboletaire marked this conversation as resolved.
Show resolved Hide resolved
</Flex>
</chakraComponents.Option>
)
Expand Down Expand Up @@ -123,14 +126,18 @@ const OptionNetwork = (props: OptionProps<any, false, GroupBase<any>>) => {
const {
data: { name, shortName },
children,
isSelected,
} = props

const iconSource = getIconSource(shortName)
return (
<chakraComponents.Option {...props}>
<Flex alignItems='center' gap={2}>
<CryptoAvatar name={name} icon={iconSource} />
<Text>{children}</Text>
<Flex justifyContent={'space-between'} alignItems={'center'} w='full'>
<Flex gap={2}>
<CryptoAvatar name={name} icon={iconSource} />
<Text>{children}</Text>
</Flex>
{isSelected && <CheckIcon color='input.dropdown.check_icon' ml='auto' />}
</Flex>
</chakraComponents.Option>
)
Expand Down
1 change: 0 additions & 1 deletion src/components/ProcessCreate/Meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const CreateProcessMeta = () => {
defaultValue: 'Provide a clear title and description to help voters understand the vote',
})}
</Text>

<InputBasic
formValue='title'
label={t('process_create.title', { defaultValue: 'Title' })}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProcessCreate/Settings/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ const Calendar = () => {
</Text>
<RadioGroup {...useBooleanRadioRegister('electionType.autoStart')} mb={6}>
<Stack direction={{ base: 'column', lg: 'row' }} gap={5} alignItems='start' justifyContent='start'>
<FormControl variant='calendar'>
<FormControl w='fit-content'>
<Radio value='1' onClick={() => clearErrors('startDate')}>
<Text as='span'>{t('form.process_create.calendar.now')}</Text>
</Radio>
</FormControl>

<Box>
<FormControl variant='calendar' mb={3}>
<FormControl w='fit-content' mb={3}>
<Radio value='0'>
<Text
as='span'
Expand Down
9 changes: 0 additions & 9 deletions src/components/ProcessCreate/Settings/index.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/ProcessCreate/StepForm/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Flex } from '@chakra-ui/react'
import { ElectionResultsTypeNames } from '@vocdoni/sdk'
import { FormProvider, SubmitHandler, useForm } from 'react-hook-form'
import CreateProcessMeta from '../Meta'
import CreateProcessSettings from '../Settings'
import Calendar from '../Settings/Calendar'
import { StepsNavigation } from '../Steps/Navigation'
import Wrapper from '../Steps/Wrapper'
import { useProcessCreationSteps } from '../Steps/use-steps'
Expand Down Expand Up @@ -53,7 +53,7 @@ export const Info = () => {
gap={8}
>
<CreateProcessMeta />
<CreateProcessSettings />
<Calendar />
</Flex>
<StepsNavigation />
</Wrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@
"update": "Update",
"upload": "Upload",
"uploader": {
"click_or_drag_and_drop": "<p1>Puja o arrossega i deixa anar aquí la llista de votants</p1><p2>(Formats permesos: CSV, XLSX i ODS)</p2>",
"click_or_drag_and_drop": "<click>Fes clic per pujar</click> <drag>o arrossega i deixa anar</drag><formats>(Formats permesos: CSV, XLSX i ODS)</formats>",
"drop_here": "Deixa anar aquí"
},
"use_read_more": {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@
"update": "Update",
"upload": "Upload",
"uploader": {
"click_or_drag_and_drop": "<p1>Upload or drag and drop the voter list here</p1><p2>(Allowed formats: CSV, XLSX, and ODS)</p2>",
"click_or_drag_and_drop": "<click>Click to upload</click> <drag>or drag and drop</drag><formats>(Allowed formats: CSV, XLSX, and ODS)</formats>",
"drop_here": "Drop here"
},
"use_read_more": {
Expand Down
Loading