Skip to content

Commit

Permalink
Merge pull request #100 from idmc-labs/project/good-practice-updates-…
Browse files Browse the repository at this point in the history
…2024-01

Project/good practice updates 2024 01
  • Loading branch information
tnagorra authored Feb 2, 2024
2 parents e441b1a + 5acd404 commit 3e744a3
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 89 deletions.
4 changes: 4 additions & 0 deletions app/Base/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function useYear(clientCode: string) {
}

function CountryProfileWithYear(props: Omit<CountryProfileProps, 'endYear'> & { clientCode: string }) {
// eslint-disable-next-line react/destructuring-assignment
const { loading, year } = useYear(props.clientCode);
if (loading || !year) {
return null;
Expand All @@ -76,6 +77,7 @@ function CountryProfileWithYear(props: Omit<CountryProfileProps, 'endYear'> & {
}

function GiddWithYear(props: Omit<GiddProps, 'endYear'>) {
// eslint-disable-next-line react/destructuring-assignment
const { loading, year } = useYear(props.clientCode);
if (loading || !year) {
return null;
Expand All @@ -89,6 +91,7 @@ function GiddWithYear(props: Omit<GiddProps, 'endYear'>) {
}

function ConflictWidgetWithYear(props: Omit<ConflictWidgetProps, 'endYear'>) {
// eslint-disable-next-line react/destructuring-assignment
const { loading, year } = useYear(props.clientCode);
if (loading || !year) {
return null;
Expand All @@ -102,6 +105,7 @@ function ConflictWidgetWithYear(props: Omit<ConflictWidgetProps, 'endYear'>) {
}

function DisasterWidgetWithYear(props: Omit<DisasterWidgetProps, 'endYear'>) {
// eslint-disable-next-line react/destructuring-assignment
const { loading, year } = useYear(props.clientCode);
if (loading || !year) {
return null;
Expand Down
12 changes: 8 additions & 4 deletions app/Base/configs/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export const goodPracticesDashboard = {
en: 'Stage',
fr: 'Organiser',
},
successFactorLabel: {
en: 'Success Factors',
fr: 'Facteurs de réussite',
},
clearButtonLabel: {
en: 'Clear All Filters',
fr: 'Effacer tous les filtres',
Expand Down Expand Up @@ -222,12 +226,12 @@ export const goodPracticesDashboard = {
fr: 'liens médias et ressources',
},
descriptionLabel: {
en: 'Description of the project (max 10,000 characters)',
fr: 'Description du projet (max 10 000 caractères)',
en: 'Description of the project',
fr: 'Description du projet',
},
descriptionsFrLabel: {
en: 'Description du projet (max 10 000 caractères)',
fr: 'Description du projet (max 10 000 caractères)',
en: 'Description du projet',
fr: 'Description du projet',
},
titleLabel: {
en: 'Name of project',
Expand Down
4 changes: 0 additions & 4 deletions app/components/FigureAnalysis/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
border: var(--tui-width-separator-thin) solid var(--tui-color-separator);
border-top: 0;

.separator {
border-bottom: var(--tui-width-separator-thin) solid var(--tui-color-separator);
}

.details {
.collapsible-children {
padding-bottom: var(--tui-spacing-medium);
Expand Down
41 changes: 0 additions & 41 deletions app/components/NumberBlock/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,4 @@
color: var(--tui-color-text-label);
font-size: var(--tui-font-size-small);
}

&.conflict {
.label,
.value {
color: var(--color-conflict);
}
}

&.disaster {
.label,
.value {
color: var(--color-disaster);
}
}

&.medium {
.value {
font-size: var(--tui-font-size-super-large);
}
}

&.large {
.value {
font-size: var(--tui-font-size-massive-large);
}
}

&.small {
.value {
font-size: var(--tui-font-size-large);
}
}

&.xsmall {
.value {
font-size: var(--tui-font-size-medium);
}
.label {
font-size: var(--tui-font-size-small);
}
}
}
4 changes: 0 additions & 4 deletions app/components/ProgressLine/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
.title {
flex-grow :1;
}

.numeral {
flex-shrink: 0;
}
}

.bottom {
Expand Down
1 change: 0 additions & 1 deletion app/components/Tabs/Tab/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
}

&.secondary {
/* border-radius: calc(1em + #{var(--tui-spacing-medium)}); */
border-radius: 0.25rem;

background-color: var(--tui-color-background);
Expand Down
26 changes: 10 additions & 16 deletions app/components/TinyMceEditorInput/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React, { useState, useCallback } from 'react';
import { _cs } from '@togglecorp/fujs';
import { isDefined, isNotDefined, _cs } from '@togglecorp/fujs';
import { InputContainer } from '@togglecorp/toggle-ui';
import { Editor } from '@tinymce/tinymce-react';

import useTranslation from '#hooks/useTranslation';
import {
goodPracticesDashboard,
} from '#base/configs/lang';
import {
TINY_MCE_KEY,
} from '#base/configs/tinyMceEditor';
import { goodPracticesDashboard } from '#base/configs/lang';
import { TINY_MCE_KEY } from '#base/configs/tinyMceEditor';

import styles from './styles.css';

Expand Down Expand Up @@ -37,21 +33,18 @@ function TinyMceEditorInput<N extends string>(props: Props<N>) {
} = props;

const strings = useTranslation(goodPracticesDashboard);

const sizeLimit = textLimit ?? 10000;
const [length, setLength] = useState(0);
const lengthExceeded = length >= sizeLimit;

const handleChange = useCallback((newText: string | undefined, editor) => {
const textLength = editor.getContent({ format: 'text' }).length;
if (textLength <= sizeLimit) {
if (isNotDefined(textLimit) || textLength <= textLimit) {
onChange(newText, name);
setLength(textLength);
}
}, [
onChange,
name,
sizeLimit,
textLimit,
]);

return (
Expand All @@ -72,17 +65,18 @@ function TinyMceEditorInput<N extends string>(props: Props<N>) {
init={{ menubar: 'edit insert format' }}
toolbar="undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | link"
/>
{value && (
{isDefined(value) && isDefined(textLimit) && (
<div className={styles.textLengthSection}>
{lengthExceeded && (
{ /* Note: only run when existed form exceed the text limit */ }
{length > textLimit && (
<span className={styles.textLimit}>
{strings.textLimitExceeded}
</span>
)}
<span>
{sizeLimit - length}
{textLimit - length}
/
{sizeLimit}
{textLimit}
</span>
</div>
)}
Expand Down
3 changes: 0 additions & 3 deletions app/components/tableHelpers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function createExternalLinkColumn<D, K>(
filterType: options?.filterType,
orderable: options?.orderable,
hideable: options?.hideable,
titleClassName: styles.title,
},
cellRenderer: ExternalLink,
cellRendererParams: (_: K, datum: D): ExternalLinkProps => {
Expand Down Expand Up @@ -93,7 +92,6 @@ export function createTextColumn<D, K>(
filterType: options?.filterType,
orderable: options?.orderable,
hideable: options?.hideable,
titleClassName: styles.title,
},
cellRenderer: Text,
columnWidth: options?.columnWidth,
Expand Down Expand Up @@ -137,7 +135,6 @@ export function createNumberColumn<D, K>(
filterType: options?.filterType,
orderable: options?.orderable,
hideable: options?.hideable,
titleClassName: styles.title,
},
cellRenderer: Numeral,
columnWidth: options?.columnWidth,
Expand Down
8 changes: 0 additions & 8 deletions app/components/tableHelpers/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
font-size: var(--tui-font-size-medium)!important;
}

&.conflict {
color: var(--color-conflict);
}

&.disaster {
color: var(--color-disaster);
}

&.number-header {
* {
justify-content: flex-end;
Expand Down
3 changes: 2 additions & 1 deletion app/views/GoodPractices/AddGoodPractice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ function AddGoodPractice(props: Props) {
error: riskyError,
setFieldValue,
validate,
// setValue,
setError,
} = useForm(
schema,
Expand Down Expand Up @@ -516,6 +515,7 @@ function AddGoodPractice(props: Props) {
value={value?.whatMakesThisPromisingPractice}
error={error?.whatMakesThisPromisingPractice}
onChange={setFieldValue}
textLimit={2000}
/>
<TinyMceEditorInput
className={styles.input}
Expand All @@ -529,6 +529,7 @@ function AddGoodPractice(props: Props) {
value={value?.descriptionOfKeyLessonsLearned}
error={error?.descriptionOfKeyLessonsLearned}
onChange={setFieldValue}
textLimit={2000}
/>
{!value?.isFrench && (
<TinyMceEditorInput
Expand Down
Loading

0 comments on commit 3e744a3

Please sign in to comment.