Skip to content

Commit c0cb12f

Browse files
committed
♻️(frontend) minor components update
- change flex property of Box component - Forward the ref of Text component - globalize tooltip padding
1 parent 0f0f812 commit c0cb12f

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

src/frontend/apps/impress/src/components/Box.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface BoxProps {
1919
$direction?: CSSProperties['flexDirection'];
2020
$display?: CSSProperties['display'];
2121
$effect?: 'show' | 'hide';
22-
$flex?: boolean;
22+
$flex?: CSSProperties['flex'];
2323
$gap?: CSSProperties['gap'];
2424
$hasTransition?: boolean | 'slow';
2525
$height?: CSSProperties['height'];
@@ -50,7 +50,7 @@ export const Box = styled('div')<BoxProps>`
5050
${({ $color }) => $color && `color: ${$color};`}
5151
${({ $direction }) => $direction && `flex-direction: ${$direction};`}
5252
${({ $display }) => $display && `display: ${$display};`}
53-
${({ $flex }) => $flex === false && `display: block;`}
53+
${({ $flex }) => $flex && `flex: ${$flex};`}
5454
${({ $gap }) => $gap && `gap: ${$gap};`}
5555
${({ $height }) => $height && `height: ${$height};`}
5656
${({ $hasTransition }) =>

src/frontend/apps/impress/src/components/Text.tsx

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { CSSProperties, ComponentPropsWithRef, ReactHTML } from 'react';
1+
import {
2+
CSSProperties,
3+
ComponentPropsWithRef,
4+
ReactHTML,
5+
forwardRef,
6+
} from 'react';
27
import styled from 'styled-components';
38

49
import { tokens } from '@/cunningham';
@@ -55,18 +60,21 @@ export const TextStyled = styled(Box)<TextProps>`
5560
`white-space: nowrap; overflow: hidden; text-overflow: ellipsis;`}
5661
`;
5762

58-
export const Text = ({
59-
className,
60-
$isMaterialIcon,
61-
...props
62-
}: ComponentPropsWithRef<typeof TextStyled>) => {
63-
return (
64-
<TextStyled
65-
as="span"
66-
$theme="greyscale"
67-
$variation="text"
68-
className={`${className || ''}${$isMaterialIcon ? ' material-icons' : ''}`}
69-
{...props}
70-
/>
71-
);
72-
};
63+
const Text = forwardRef<HTMLElement, ComponentPropsWithRef<typeof TextStyled>>(
64+
({ className, $isMaterialIcon, ...props }, ref) => {
65+
return (
66+
<TextStyled
67+
ref={ref}
68+
as="span"
69+
$theme="greyscale"
70+
$variation="text"
71+
className={`${className || ''}${$isMaterialIcon ? ' material-icons' : ''}`}
72+
{...props}
73+
/>
74+
);
75+
},
76+
);
77+
78+
Text.displayName = 'Text';
79+
80+
export { Text };

src/frontend/apps/impress/src/cunningham/cunningham-style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,3 +532,10 @@ input:-webkit-autofill:focus {
532532
.c__toast__container {
533533
z-index: 10000;
534534
}
535+
536+
/**
537+
* Tooltip
538+
*/
539+
.c__tooltip {
540+
padding: 4px 6px;
541+
}

src/frontend/apps/impress/src/features/docs/doc-header/components/DocTitle.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from '@openfun/cunningham-react';
88
import React, { useCallback, useEffect, useRef, useState } from 'react';
99
import { useTranslation } from 'react-i18next';
10-
import { createGlobalStyle } from 'styled-components';
1110

1211
import { Box, Text } from '@/components';
1312
import { useCunninghamTheme } from '@/cunningham';
@@ -22,12 +21,6 @@ import {
2221
import { useResponsiveStore } from '@/stores';
2322
import { isFirefox } from '@/utils/userAgent';
2423

25-
const DocTitleStyle = createGlobalStyle`
26-
.c__tooltip {
27-
padding: 4px 6px;
28-
}
29-
`;
30-
3124
interface DocTitleProps {
3225
doc: Doc;
3326
}
@@ -126,7 +119,6 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
126119

127120
return (
128121
<>
129-
<DocTitleStyle />
130122
<Tooltip content={t('Rename')} placement="top">
131123
<Box
132124
as="h2"

0 commit comments

Comments
 (0)