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

♻️(frontend) replace Text grommet #2427

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Versioning](https://semver.org/spec/v2.0.0.html).

- Replace grommet Heading (#2410)
- Replace all the loaders by Cunningham Loader (#2436)
- Replace grommet Text (#2427)
- Upgrade to python 3.11
- Upgrade channels and channels-redis to version 4

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Box, Button, Grid } from 'grommet';
import { AddCircle } from 'grommet-icons';
import { Nullable } from 'lib-common';
import {
Classroom,
ClassroomSVG,
ContentCard,
TextTruncated,
} from 'lib-components';
import { Classroom, ClassroomSVG, ContentCard, Text } from 'lib-components';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';

Expand Down Expand Up @@ -55,9 +50,14 @@ const SelectContentCard = ({
title={content.title || ''}
>
{content.description && (
<TextTruncated size="0.688rem" color="grey" title={content.description}>
<Text
size="small"
truncate={5}
color="grey"
title={content.description}
>
{content.description}
</TextTruncated>
</Text>
)}
</ContentCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Select } from '@openfun/cunningham-react';
import { Box, Pagination, Paragraph, Text } from 'grommet';
import { Box, Pagination, Paragraph } from 'grommet';
import { Maybe } from 'lib-common';
import { BoxLoader, FileDepository, Heading } from 'lib-components';
import { BoxLoader, FileDepository, Heading, Text } from 'lib-components';
import React, { FocusEvent, useState } from 'react';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, Button, Paragraph, Text } from 'grommet';
import { Box, Button, Paragraph } from 'grommet';
import {
PlusSVG,
Text,
UploadManagerStatus,
UploadableObjectProgress,
formatSizeErrorScale,
Expand Down Expand Up @@ -161,7 +162,9 @@ export const UploadFiles = () => {
<UploadableObjectProgress
progress={uploadManagerState[state.objectId].progress}
/>
{intl.formatMessage(messages.uploadingFile)}
<Text size="small">
{intl.formatMessage(messages.uploadingFile)}
</Text>
</Box>
))}
</Box>
Expand All @@ -182,10 +185,10 @@ export const UploadFiles = () => {
</Box>
<Box direction="row">
<Box justify="start" flex="shrink">
<Text alignSelf="center">{bytesToSize(file.size)}</Text>
<Text textAlign="center">{bytesToSize(file.size)}</Text>
</Box>
<Box justify="end" flex>
<Text alignSelf="end">
<Text textAlign="end">
{DateTime.now().toFormat('dd/MM/yyyy')}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Anchor, Box, Text } from 'grommet';
import { Anchor, Box } from 'grommet';
import { Breakpoints } from 'lib-common';
import { DepositedFile, truncateFilename, useResponsive } from 'lib-components';
import {
DepositedFile,
Text,
truncateFilename,
useResponsive,
} from 'lib-components';
import { DateTime } from 'luxon';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
Expand Down Expand Up @@ -62,17 +67,13 @@ export const DepositedFileRow = ({ file }: DepositedFileProps) => {
pad="medium"
round="small"
>
<Box direction="row" fill>
<Box direction="row" fill align="center">
<Box justify="start" gap="small" flex>
<Text size="medium">{file.author_name}</Text>
<Text weight="medium">{file.author_name}</Text>
</Box>
{uploadedOn && (
<Box justify="start" flex="shrink">
<Text
size="small"
wordBreak="keep-all"
margin={{ right: 'xxsmall' }}
>
<Text size="small" className="mr-t">
{uploadedOnDate}&nbsp;{uploadedOnTime}
</Text>
</Box>
Expand Down Expand Up @@ -105,7 +106,7 @@ export const DepositedFileRow = ({ file }: DepositedFileProps) => {

<Box direction="row" fill>
<Box justify="start" flex>
<Text title={file.filename} weight={file.read ? 'normal' : 'bolder'}>
<Text title={file.filename} weight={file.read ? 'regular' : 'bold'}>
{isSmallerBreakpoint(breakpoint, Breakpoints.large)
? truncateFilename(file.filename, 40)
: breakpoint === 'large'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Button, Grid } from 'grommet';
import { AddCircle, DocumentStore } from 'grommet-icons';
import { Nullable } from 'lib-common';
import { ContentCard, FileDepository, TextTruncated } from 'lib-components';
import { ContentCard, FileDepository, Text } from 'lib-components';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';

Expand Down Expand Up @@ -52,9 +52,14 @@ const SelectContentCard = ({
title={content.title || ''}
>
{content.description && (
<TextTruncated size="0.688rem" color="grey" title={content.description}>
<Text
size="small"
truncate={5}
color="grey"
title={content.description}
>
{content.description}
</TextTruncated>
</Text>
)}
</ContentCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Input } from '@openfun/cunningham-react';
import { Box, Button, Text } from 'grommet';
import { Box, Button } from 'grommet';
import { Breakpoints } from 'lib-common';
import { WhiteCard, WizardLayout, useResponsive } from 'lib-components';
import { Text, WhiteCard, WizardLayout, useResponsive } from 'lib-components';
import {
LanguageSelector,
MARKDOWN_EDITOR_ROUTE,
Expand Down Expand Up @@ -84,12 +84,7 @@ export const MarkdownWizard = ({ markdownDocumentId }: MarkdownWizardProps) => {
: 'xlarge',
}}
>
<Text
color="blue-active"
margin={{ bottom: 'small' }}
size="1rem"
textAlign="center"
>
<Text className="mb-t" textAlign="center">
{intl.formatMessage(messages.descriptionText)}
</Text>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Input } from '@openfun/cunningham-react';
import { Button, Form, Text } from 'grommet';
import { Button, Form } from 'grommet';
import { Maybe } from 'lib-common';
import {
Document,
Text,
modelName,
updateResource,
useDocument,
Expand Down Expand Up @@ -89,7 +90,11 @@ export const DashboardDocumentTitleForm = ({
margin={{ top: 'small' }}
/>
{udpated && (
<Text margin="small" color="status-ok">
<Text
color="var(--c--theme--colors--success-500)"
className="ml-s"
weight="bold"
>
{intl.formatMessage(messages.updateSuccessful)}
</Text>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Text } from 'grommet';
import { IFetchResponseError } from 'lib-components';
import { IFetchResponseError, Text } from 'lib-components';
import React from 'react';

interface MutationFieldErrorProps<T> {
Expand All @@ -18,7 +17,7 @@ export const MutationFieldError = <T,>({
.map((errorObject, index) => (
<React.Fragment key={index}>
{errorObject[fieldName]?.map((message) => (
<Text color="status-error" key={message}>
<Text color="clr-danger-300" key={message}>
{message}
</Text>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Input, Loader } from '@openfun/cunningham-react';
import { Box, Button, Text } from 'grommet';
import { Box, Button } from 'grommet';
import { AddCircle, Trash } from 'grommet-icons';
import {
CopyClipboard,
Expand All @@ -8,6 +8,7 @@ import {
ErrorMessage,
List,
Playlist,
Text,
Video,
} from 'lib-components';
import React, { Fragment, useState } from 'react';
Expand Down Expand Up @@ -130,9 +131,10 @@ export const PlaylistPortabilityList = ({
direction="row-responsive"
gap="medium"
align="center"
pad="small"
>
<Text weight="bold">{reachableFromPlaylist.title}</Text>
<Text size="small" color="dark-4">
<Text size="small" color="clr-primary-800">
{reachableFromPlaylist.id}
</Text>
</Box>
Expand Down Expand Up @@ -193,7 +195,7 @@ export const PlaylistPortability = ({ object }: PlaylistPortabilityProps) => {
content = (
<React.Fragment>
<Box align="center" direction="row" pad={{ top: 'small' }}>
<Text role="heading" margin="small">
<Text role="heading" className="m-s">
<CopyClipboard
copyId={`playlist-${playlist?.id}`}
text={
Expand Down Expand Up @@ -252,7 +254,7 @@ export const PlaylistPortability = ({ object }: PlaylistPortabilityProps) => {
background="status-warning"
width="large"
>
<Text>
<Text color="clr-primary-800" size="large">
<FormattedMessage {...messages.shareWithPlaylistDetails} />
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ContentCard,
Document,
PlaySVG,
TextTruncated,
Text,
Video,
WebinarSVG,
videoSize,
Expand Down Expand Up @@ -106,9 +106,14 @@ const SelectContentCard = ({
title={content.title || ''}
>
{content.description && (
<TextTruncated size="0.688rem" color="grey" title={content.description}>
<Text
size="small"
truncate={5}
color="grey"
title={content.description}
>
{content.description}
</TextTruncated>
</Text>
)}
</ContentCard>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Grommet, Tab, Tabs, Text } from 'grommet';
import { Box, Grommet, Tab, Tabs } from 'grommet';
import { deepMerge } from 'grommet/utils';
import { Document as DocumentIcon } from 'grommet-icons';
import { theme as baseTheme } from 'lib-common';
Expand All @@ -9,6 +9,7 @@ import {
LiveModeType,
PlaySVG,
Playlist,
Text,
Video,
WebinarSVG,
appNames,
Expand Down Expand Up @@ -57,12 +58,7 @@ export interface RichTabTitleProps {
export const RichTabTitle = ({ icon, label }: RichTabTitleProps) => (
<Box direction="row" align="center">
{icon}
<Text
size="0.938rem"
color="blue-active"
margin={{ left: 'xsmall' }}
weight="bold"
>
<Text className="ml-t" weight="bold">
{label}
</Text>
</Box>
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/apps/lti_site/components/VideoWizard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Box, Button, Text } from 'grommet';
import { Box, Button } from 'grommet';
import { Breakpoints } from 'lib-common';
import {
ErrorComponents,
Text,
WhiteCard,
WizardLayout,
builderDashboardRoute,
Expand Down Expand Up @@ -91,7 +92,7 @@ const VideoWizard = () => {
: 'xlarge',
}}
>
<Text color="blue-active" size="1rem" textAlign="center">
<Text textAlign="center">
{intl.formatMessage(messages.descriptionText)}
</Text>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Field, Input } from '@openfun/cunningham-react';
import { Box, Text } from 'grommet';
import { Box } from 'grommet';
import { Alert } from 'grommet-icons';
import { ButtonLoader } from 'lib-components';
import { ButtonLoader, Text } from 'lib-components';
import { useEffect, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { Link, useLocation, useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -110,15 +110,11 @@ export const LoginForm = () => {
text={error?.password?.join(' ')}
/>
</Field>
<Link to={routes.PASSWORD_RESET.path}>
<Text
color="blue-active"
weight="normal"
style={{ textDecoration: 'underline' }}
size="xsmall"
>
{intl.formatMessage(messages.passwordLost)}
</Text>
<Link
to={routes.PASSWORD_RESET.path}
style={{ color: 'var(--c--theme--colors--primary-500)' }}
>
<Text size="small">{intl.formatMessage(messages.passwordLost)}</Text>
</Link>
{error?.detail && (
<Box
Expand All @@ -129,9 +125,7 @@ export const LoginForm = () => {
gap="small"
>
<Alert size="medium" color="#df8c00" />
<Text weight="bold" size="small">
{error?.detail}
</Text>
<Text weight="bold">{error?.detail}</Text>
</Box>
)}
<Box flex={false} margin={{ top: 'medium' }}>
Expand Down
Loading