Skip to content

Commit

Permalink
feat: translate web-components from header to inputs/new
Browse files Browse the repository at this point in the history
  • Loading branch information
flagrede committed Sep 10, 2024
1 parent 4570801 commit 43d5704
Show file tree
Hide file tree
Showing 71 changed files with 600 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
'lingui/no-unlocalized-strings': [
1,
{
ignoreFunction: ['test', 'makeStyles', 'withStyles'],
ignoreFunction: ['test', 'makeStyles', 'withStyles', 'cn'],
ignoreAttribute: [
'allow',
'sx',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ const Photo = ({
src,
caption,
credit,
locationText,
sx = [],
}: CardMediaProps & { caption?: string; credit?: string }): JSX.Element => {
}: CardMediaProps & {
caption?: string;
credit?: string;
locationText: string;
}): JSX.Element => {
return (
<Card sx={[{ height: [216, 293], position: 'relative' }, ...sxToArray(sx)]}>
<CardMedia
Expand All @@ -19,6 +24,7 @@ const Photo = ({
/>
{(caption || credit) && (
<FileDropBottomBar
locationText={locationText}
caption={caption}
credit={credit}
sx={{ position: 'absolute', bottom: 0 }}
Expand Down
2 changes: 0 additions & 2 deletions web-components/src/components/credits/CreditsGauge.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import Grid from '@mui/material/Grid';
import { Theme } from '@mui/material/styles';
import { makeStyles } from 'tss-react/mui';

import { pluralize } from '../../utils/pluralize';
import Gauge from './Gauge';
import GaugeText from './GaugeText';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable lingui/no-unlocalized-strings */
import { GradientBadgeVariant } from './GradientBadge.types';

export const GradientBadgeVariantMapping: {
Expand Down
1 change: 1 addition & 0 deletions web-components/src/components/header/Header.mock.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable lingui/no-unlocalized-strings */
import { Item } from './components/HeaderMenuItem/HeaderMenuItem';

export const headerMenuItemsMock: Item[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ import { getUserMenuItemsMock } from './components/UserMenuItems.mock';

const REGEN_TEST_ADDRESS = 'regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46';

export const ExtraComponent = (): JSX.Element => {
type Props = {
loginText: string;
logoutText: string;
avatarAlt: string;
};

export const ExtraComponent = ({
loginText,
avatarAlt,
logoutText,
}: Props): JSX.Element => {
const [address, setAddress] = useState('');
const userMenuItems = getUserMenuItemsMock({
linkComponent: NavLink,
Expand All @@ -18,6 +28,9 @@ export const ExtraComponent = (): JSX.Element => {
<Box display="flex" justifyContent="center" alignItems="center">
{address && (
<UserMenuItems
nameOrAddress={address}
avatarAlt={avatarAlt}
logoutText={logoutText}
avatar={''}
disconnect={() => setAddress('')}
pathname={''}
Expand All @@ -30,7 +43,7 @@ export const ExtraComponent = (): JSX.Element => {
size="small"
onClick={() => setAddress(REGEN_TEST_ADDRESS)}
>
{'login'}
{loginText}
</ContainedButton>
)}
</Box>
Expand Down
8 changes: 7 additions & 1 deletion web-components/src/components/header/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ Default.args = {
absolute: true,
color: 'black',
borderBottom: false,
extras: <ExtraComponent />,
extras: (
<ExtraComponent
avatarAlt="default avatar"
logoutText="Log out"
loginText="Login"
/>
),
};

Default.argTypes = {};

This file was deleted.

38 changes: 0 additions & 38 deletions web-components/src/components/header/MarketplaceLaunchBanner.tsx

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Link from '@mui/material/Link';
import { makeStyles } from 'tss-react/mui';

import { cn } from '../../../utils/styles/cn';

type UseNavLinkStylesParams = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable lingui/no-unlocalized-strings */
import BridgeIcon from '../../icons/BridgeIcon';
import CreditsIcon from '../../icons/CreditsIcon';
import { HeaderDropdownItemProps } from './HeaderDropdown/HeaderDropdown.Item';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface UserMenuItemsProps extends HeaderMenuItemBase {
nameOrAddress?: string | null;
avatar: string;
userMenuItems: HeaderDropdownItemProps[];
logoutText: string;
avatarAlt: string;
disconnect: () => void;
}

Expand Down

This file was deleted.

13 changes: 9 additions & 4 deletions web-components/src/components/image-crop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { makeStyles } from 'tss-react/mui';

import { CancelButtonFooter } from '../organisms/CancelButtonFooter/CancelButtonFooter';
import { getCroppedImg } from './canvas-utils';
import { APPLY, UPDATE, UPLOADING } from './ImageCrop.constants';

import 'react-image-crop/dist/ReactCrop.css';

Expand All @@ -19,6 +18,9 @@ export interface ImageCropProps {
fixedCrop: Partial<Crop>;
isCropSubmitDisabled?: boolean;
isIgnoreCrop?: boolean;
uploadText: string;
updateText: string;
applyText: string;
children?: React.ReactNode;
}

Expand Down Expand Up @@ -76,6 +78,9 @@ export default function ImageCrop({
fixedCrop,
isCropSubmitDisabled,
isIgnoreCrop = false,
uploadText,
updateText,
applyText,
children,
}: ImageCropProps): JSX.Element {
const { classes } = useStyles();
Expand Down Expand Up @@ -183,12 +188,12 @@ export default function ImageCrop({
<div className="h-20">
<CircularProgress size={20} color="secondary" />
</div>
<span className="ml-5">{UPLOADING}</span>
<span className="ml-5">{uploadText}</span>
</>
) : isIgnoreCrop ? (
UPDATE
updateText
) : (
APPLY
applyText
)}
</>
}
Expand Down
3 changes: 3 additions & 0 deletions web-components/src/components/inputs/ControlledTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface ControlledTextFieldProps
description?: string;
label?: string;
optional?: boolean | string;
exampleText?: string;
onExampleClick?: () => void;
sx?: SxProps<Theme>;
}
Expand All @@ -30,6 +31,7 @@ export default function ControlledTextField({
meta,
optional,
startAdornment,
exampleText,
onExampleClick,
defaultStyle = true,
sx,
Expand All @@ -54,6 +56,7 @@ export default function ControlledTextField({
<FieldFormControl
label={label}
description={description}
exampleText={exampleText}
onExampleClick={onExampleClick}
disabled={form.isSubmitting}
optional={optional}
Expand Down
3 changes: 3 additions & 0 deletions web-components/src/components/inputs/FieldFormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props extends FieldProps, DefaultStyleProps {
disabled?: boolean;
optional?: boolean | string;
label?: string;
exampleText?: string;
onExampleClick?: () => void;
}

Expand Down Expand Up @@ -83,6 +84,7 @@ export default function FieldFormControl({
className,
sx,
optional,
exampleText,
onExampleClick,
defaultStyle = true,
forceDefaultStyle = false,
Expand Down Expand Up @@ -124,6 +126,7 @@ export default function FieldFormControl({
label={label}
optional={optional}
description={description}
exampleText={exampleText}
onExampleClick={onExampleClick}
disabled={disabled}
/>
Expand Down
4 changes: 3 additions & 1 deletion web-components/src/components/inputs/FormLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface Props {
disabled?: boolean;
optional?: boolean | string;
label?: string;
exampleText?: string;
onExampleClick?: () => void;
}

Expand All @@ -22,6 +23,7 @@ export default function FormLabel({
disabled,
className,
optional,
exampleText,
onExampleClick,
}: Props): JSX.Element {
return (
Expand All @@ -42,7 +44,7 @@ export default function FormLabel({
onClick={onExampleClick}
sx={{ color: 'secondary.main', cursor: 'pointer' }}
>
&nbsp;See an example»
&nbsp;{exampleText}
</Box>
)}
</Body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ interface AuxiliaryLabelProps {
availableAmount: number;
denom: string;
auxiliaryLabel?: string;
availableLabel: string;
className?: string;
}

export const AuxiliaryLabel = ({
availableAmount,
denom,
auxiliaryLabel,
availableLabel,
className,
}: AuxiliaryLabelProps): JSX.Element => {
const { classes: styles } = useAmountFieldStyles();
Expand All @@ -29,7 +31,7 @@ export const AuxiliaryLabel = ({
<span className={styles.availableLabel}>{auxiliaryLabel}</span>
)}
<span>
<span className={styles.availableLabel}>Available:</span>{' '}
<span className={styles.availableLabel}>{`${availableLabel}:`}</span>{' '}
<span className={styles.availableAmount}>
{getFormattedNumber(availableAmount)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { useAmountFieldStyles } from './AmountField.styles';
import { AmountLabelProps } from './AmountField.types';

export const AmountLabel: React.FC<React.PropsWithChildren<AmountLabelProps>> =
({ label, auxiliaryLabel, availableAmount, denom }) => {
({ label, auxiliaryLabel, availableAmount, availableLabel, denom }) => {
const { classes: styles } = useAmountFieldStyles();
return (
<Grid container justifyContent="space-between">
<span className={styles.mainLabel}>{label}</span>
<AuxiliaryLabel
availableLabel={availableLabel}
availableAmount={availableAmount}
auxiliaryLabel={auxiliaryLabel}
denom={denom}
Expand Down
Loading

0 comments on commit 43d5704

Please sign in to comment.