Skip to content

Commit

Permalink
Added Brasilian Portugese to locales, moved textFieldValue from App t…
Browse files Browse the repository at this point in the history
…o Dialog component
  • Loading branch information
ransome1 committed Feb 11, 2025
1 parent 393a5be commit 81b6992
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 38 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const App = (): JSX.Element => {
const [attributes, setAttributes] = useState<Attributes | null>(null)
const [isSettingsOpen, setIsSettingsOpen] = useState<boolean>(false)
const [contextMenu, setContextMenu] = useState<ContextMenu | null>(null)
const [textFieldValue, setTextFieldValue] = useState<string>('')
const [promptItem, setPromptItem] = useState<PromptItem | null>(null)
const [triggerArchiving, setTriggerArchiving] = useState<boolean>(false)
const [theme, setTheme] = useState(
Expand Down Expand Up @@ -195,8 +194,6 @@ const App = (): JSX.Element => {
setAttributeFields={setAttributeFields}
setSnackBarSeverity={setSnackBarSeverity}
setSnackBarContent={setSnackBarContent}
textFieldValue={textFieldValue}
setTextFieldValue={setTextFieldValue}
settings={settings}
/>
) : null}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/Dialog/AutoSuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const AutoSuggestComponent: React.FC<AutoSuggestComponentProps> = ({
onKeyDown: handleKeyDown,
'test-id': 'dialog-autosuggest-textfield'
}

useEffect(() => {
textFieldRef.current?.focus()
}, [textFieldRef])
Expand Down
8 changes: 5 additions & 3 deletions src/renderer/Dialog/DatePicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@

}
}
// .MuiPickersSlideTransition-root {
// max-height: 13em;
// }
button {
border-radius: Variables.$radius;
&.MuiPickersDay-today {
border: inherit;
background: Variables.$mid-grey;
}
}
.darkTheme {
button.MuiPickersDay-today {
color: black;
}
}
}
11 changes: 4 additions & 7 deletions src/renderer/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ interface DialogComponentProps extends WithTranslation {
setAttributeFields: React.Dispatch<React.SetStateAction<TodoObject | null>>
setSnackBarSeverity: React.Dispatch<React.SetStateAction<AlertColor | undefined>>
setSnackBarContent: React.Dispatch<React.SetStateAction<string | null>>
textFieldValue: string
setTextFieldValue: React.Dispatch<React.SetStateAction<string>>
settings: Settings
t: typeof i18n.t
}
Expand All @@ -42,19 +40,18 @@ const DialogComponent: React.FC<DialogComponentProps> = memo(
setAttributeFields,
setSnackBarSeverity,
setSnackBarContent,
textFieldValue,
setTextFieldValue,
settings,
t
}) => {
const numRowsWithContent = textFieldValue
?.split('\n')
.filter((line) => line.trim() !== '').length
const [priority, setPriority] = useState<string>('-')
const [dueDate, setDueDate] = useState<string | null>(null)
const [thresholdDate, setThresholdDate] = useState<string | null>(null)
const [recurrence, setRecurrence] = useState<string | null>(null)
const [pomodoro, setPomodoro] = useState<number | string>(0)
const [textFieldValue, setTextFieldValue] = useState<string>('')
const numRowsWithContent = textFieldValue
?.split('\n')
.filter((line) => line.trim() !== '').length

const handleAdd = (): void => {
try {
Expand Down
9 changes: 3 additions & 6 deletions src/renderer/Grid/Row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
display: flex;
flex-wrap: wrap;
gap: 0.25em;
padding: 0.4em;
padding: 0.75em 0.4em;
.MuiCheckbox-root {
padding: 0;
margin: 0 0.25em;
}
&[data-complete='true'],
&[data-hidden='true'] {
Expand All @@ -29,10 +30,6 @@

.darkTheme {
.row {
border-left: solid 0.2em Variables.$dark-grey;
border-bottom: solid 1px Variables.$dark-grey;
&.group {
border: none;
}
border-color: Variables.$dark-grey;
}
}
38 changes: 20 additions & 18 deletions src/renderer/Header/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Autocomplete, {
import OptionComponent from './Option'
import InputComponent from './Input'
import { withTranslation, WithTranslation } from 'react-i18next'
import LanguageSelector, { i18n } from '../Settings/LanguageSelector'
import './Search.scss'

const { ipcRenderer, store } = window.api
Expand Down Expand Up @@ -38,34 +39,18 @@ const getOptionLabel = (option: string | SearchFilter): string => {
return ''
}

const filterOptions = (
options: string | SearchFilter[],
params: { inputValue: string }
): SearchFilter[] => {
const filter = createFilterOptions<SearchFilter>()
const filtered: SearchFilter[] = filter(options as SearchFilter[], params)
const { inputValue } = params
const isExisting = filtered.some((filter) => filter.label && filter.label.includes(inputValue))
if (inputValue !== '' && !isExisting) {
filtered.push({
inputValue,
title: `Create new filter: <code>${inputValue}</code>`
})
}
return filtered
}

interface SearchComponentProps extends WithTranslation {
headers: HeadersObject | null
settings: Settings
searchString: string
setSearchString: React.Dispatch<React.SetStateAction<string>>
searchFieldRef: React.RefObject<HTMLInputElement>
setPromptItem: React.Dispatch<React.SetStateAction<PromptItem | null>>
t: typeof i18n.t
}

const SearchComponent: React.FC<SearchComponentProps> = memo(
({ headers, settings, searchString, setSearchString, searchFieldRef, setPromptItem }) => {
({ headers, settings, searchString, setSearchString, searchFieldRef, setPromptItem, t }) => {
const [searchFilters, setSearchFilters] = useState<SearchFilter[]>(store.getFilters('search'))
const [isAutocompleteOpen, setIsAutocompleteOpen] = useState(false)

Expand Down Expand Up @@ -105,6 +90,23 @@ const SearchComponent: React.FC<SearchComponentProps> = memo(
[searchFieldRef, isAutocompleteOpen]
)

const filterOptions = (
options: string | SearchFilter[],
params: { inputValue: string },
): SearchFilter[] => {
const filter = createFilterOptions<SearchFilter>()
const filtered: SearchFilter[] = filter(options as SearchFilter[], params)
const { inputValue } = params
const isExisting = filtered.some((filter) => filter.label && filter.label.includes(inputValue))
if (inputValue !== '' && !isExisting) {
filtered.push({
inputValue,
title: `${t('search.filters.create')}: <code>${inputValue}</code>`
})
}
return filtered
}

useEffect(() => {
document.addEventListener('keydown', handleKeyDown)
return (): void => {
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/Settings/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import es from '../../locales/es.json'
import fr from '../../locales/fr.json'
import zh from '../../locales/zh.json'
import pt from '../../locales/pt.json'
import pt_br from '../../locales/pt-br.json'
import jp from '../../locales/jp.json'
import tr from '../../locales/tr.json'
import hu from '../../locales/hu.json'
Expand All @@ -27,11 +28,14 @@ import 'dayjs/locale/es'
import 'dayjs/locale/fr'
import 'dayjs/locale/zh'
import 'dayjs/locale/pt'
import 'dayjs/locale/pt-br'
import 'dayjs/locale/tr'
import 'dayjs/locale/hu'
import 'dayjs/locale/cs'
import 'dayjs/locale/pl'
import 'dayjs/locale/ru'
import 'dayjs/locale/ko'
import 'dayjs/locale/hi'

const { store } = window.api

Expand All @@ -44,6 +48,7 @@ const options: i18n.InitOptions = {
fr: { translation: fr },
zh: { translation: zh },
pt: { translation: pt },
'pt-br': { translation: pt_br },
jp: { translation: jp },
tr: { translation: tr },
hu: { translation: hu },
Expand All @@ -62,6 +67,7 @@ const options: i18n.InitOptions = {
'fr',
'zh',
'pt',
'pt-br',
'jp',
'tr',
'hu',
Expand Down Expand Up @@ -99,7 +105,8 @@ const friendlyLanguageName: Record<string, string> = {
es: 'Español',
fr: 'Français',
zh: '简体中文',
pt: 'Português',
pt: 'Português (Portugal)',
'pt-br': 'Português (Brasil)',
jp: '日本語',
tr: 'Türkçe',
hu: 'Magyar',
Expand Down

0 comments on commit 81b6992

Please sign in to comment.