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

feat: upgrade styled-components to v6 #502

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
327aad4
refactor: remove css with styled components container queries
rodleyorosa Sep 5, 2024
4ffac80
feat: remove css file
rodleyorosa Sep 5, 2024
c04f42f
Merge branch 'devel' into SHELL-107-Remove-css-with-container-queries…
rodleyorosa Sep 5, 2024
9a97487
fix: fix tests and revert css
rodleyorosa Sep 20, 2024
de37b0b
fix: fix test
rodleyorosa Sep 30, 2024
926244b
Update src/shell/boards/board-tab.tsx
rodleyorosa Sep 30, 2024
954b51d
Merge branch 'SHELL-107-Remove-css-with-container-queries-when-contai…
rodleyorosa Sep 30, 2024
f94ad07
fix: apply review hints
rodleyorosa Sep 30, 2024
fa3f5de
Merge remote-tracking branch 'origin' into SHELL-107-Remove-css-with-…
rodleyorosa Sep 30, 2024
8f22990
Merge branch 'devel' into SHELL-107-Remove-css-with-container-queries…
rodleyorosa Oct 2, 2024
cd7e826
Merge remote-tracking branch 'origin/devel' into SHELL-107-Remove-css…
beawar Oct 17, 2024
9f64c2c
build(deps): update ds version
beawar Oct 17, 2024
282e116
build(deps): update ds and preview
beawar Oct 29, 2024
61bf8fa
Merge remote-tracking branch 'origin/devel' into SHELL-107-Remove-css…
beawar Oct 29, 2024
8c56219
fix: prevent action props to be passed to dom
beawar Nov 7, 2024
e69432a
refactor: add $ prefix on styled component custom props
beawar Nov 14, 2024
2c0eadb
Merge remote-tracking branch 'origin/devel' into SHELL-107-Remove-css…
beawar Nov 18, 2024
aab8781
fix: update invalid flex aligment
beawar Nov 18, 2024
f451b8a
Merge branch 'devel' into SHELL-107-Remove-css-with-container-queries…
beawar Nov 27, 2024
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
217 changes: 137 additions & 80 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
"@fontsource/roboto": "^5.0.8",
"@sentry/browser": "^7.103.0",
"@tinymce/tinymce-react": "^4.3.2",
"@zextras/carbonio-design-system": "^7.1.1",
"@zextras/carbonio-ui-preview": "^2.1.0",
"@zextras/carbonio-design-system": "file:../carbonio-design-system/zextras-carbonio-design-system-0.0.0-semantically-released.tgz",
"@zextras/carbonio-ui-preview": "file:../carbonio-ui-preview/zextras-carbonio-ui-preview-0.0.0-semantically-released.tgz",
"darkreader": "^4.9.79",
"history": "^5.3.0",
"i18next": "^22.5.1",
Expand All @@ -122,21 +122,19 @@
"react-dom": "^17.0.2",
"react-i18next": "^12.3.1",
"react-router-dom": "^5.3.4",
"styled-components": "^5.3.11",
"styled-components": "^6.1.13",
"tinymce": "^6.8.4",
"ua-parser-js": "^1.0.37",
"zustand": "^4.5.1"
},
"peerDependencies": {
"@zextras/carbonio-design-system": "^7.1.1",
"@zextras/carbonio-ui-preview": "^2.1.0",
"core-js": "^3.31.1",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^12.3.1",
"react-router-dom": "^5.3.4",
"styled-components": "^5.3.11"
"styled-components": "^6.1.13"
},
"peerDependenciesMeta": {
"@zextras/carbonio-design-system": {
Expand Down
4 changes: 2 additions & 2 deletions src/boot/theme-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '@zextras/carbonio-design-system';
import { auto, disable, enable, setFetchMethod } from 'darkreader';
import { map, reduce } from 'lodash';
import type { DefaultTheme, SimpleInterpolation } from 'styled-components';
import type { DefaultTheme } from 'styled-components';
import { createGlobalStyle, css } from 'styled-components';

import { useGetPrimaryColor } from './use-get-primary-color';
Expand Down Expand Up @@ -106,7 +106,7 @@ const GlobalStyle = createGlobalStyle<GlobalStyledProps>`
html {
font-size: ${({ baseFontSize }): string => `${baseFontSize}%`};
}
${({ theme }): SimpleInterpolation =>
${({ theme }): ReturnType<typeof css> =>
map(
theme.globalCursors,
(cursor) => css`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Tooltip
} from '@zextras/carbonio-design-system';
import { useTranslation } from 'react-i18next';
import type { SimpleInterpolation } from 'styled-components';
import styled from 'styled-components';

import { BASE_FONT_SIZE, SCALING_OPTIONS } from '../../../constants';
Expand All @@ -30,7 +29,7 @@ const ScalingSliderContainer = styled(Container)`
`;

const ExampleContainer = styled(Container)<{ $fontSize: number | undefined }>`
font-size: ${({ $fontSize }): SimpleInterpolation => $fontSize && `${$fontSize}%`};
font-size: ${({ $fontSize }): string | undefined | 0 => $fontSize && `${$fontSize}%`};
`;

const ExampleText = styled(Text)`
Expand Down
27 changes: 13 additions & 14 deletions src/shell/boards/board-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
Tooltip
} from '@zextras/carbonio-design-system';
import { debounce, isEmpty, map, noop, size } from 'lodash';
import type { SimpleInterpolation } from 'styled-components';
import styled, { css } from 'styled-components';

import { AppBoard } from './board';
Expand Down Expand Up @@ -57,7 +56,7 @@ export const BOARD_DEFAULT_POSITION: Pick<CSSProperties, 'top' | 'left' | 'right
bottom: '0'
};

const BoardContainerComp = styled.div<{ expanded: boolean; minimized: boolean }>`
const BoardContainerComp = styled.div<{ $expanded: boolean; $minimized: boolean }>`
position: fixed;
width: calc(100vw - ${PRIMARY_BAR_WIDTH});
height: calc(100vh - ${HEADER_BAR_HEIGHT});
Expand All @@ -66,14 +65,14 @@ const BoardContainerComp = styled.div<{ expanded: boolean; minimized: boolean }>
background-color: rgba(0, 0, 0, 0);
pointer-events: none;
z-index: ${BOARD_CONTAINER_ZINDEX};
${({ expanded }): SimpleInterpolation =>
expanded &&
${({ $expanded }): ReturnType<typeof css> | false =>
$expanded &&
css`
background-color: rgba(0, 0, 0, 0.5);
pointer-events: auto;
`}
${({ minimized }): SimpleInterpolation =>
minimized &&
${({ $minimized }): ReturnType<typeof css> | false =>
$minimized &&
css`
display: none;
`}
Expand All @@ -83,20 +82,20 @@ const OverflowContainer = styled(Container)`
overflow: auto;
`;

const Board = styled(Container)<{ expanded: boolean }>`
const Board = styled(Container)<{ $expanded: boolean }>`
z-index: 5;
position: absolute;
${BOARD_DEFAULT_POSITION};

${({ width }): SimpleInterpolation =>
${({ width }): ReturnType<typeof css> | false =>
!width &&
css`
/* default width and aspect ratio */
aspect-ratio: 4 / 3;
width: auto;
`}

${({ height }): SimpleInterpolation =>
${({ height }): ReturnType<typeof css> | false =>
!height &&
css`
/* default height */
Expand All @@ -116,8 +115,8 @@ const Board = styled(Container)<{ expanded: boolean }>`
pointer-events: auto;
max-height: 100%;
max-width: 100%;
${({ expanded }): SimpleInterpolation =>
expanded &&
${({ $expanded }): ReturnType<typeof css> | false =>
$expanded &&
css`
height: calc(100% - 1.5rem) !important;
width: calc(100% - 3rem) !important;
Expand Down Expand Up @@ -347,12 +346,12 @@ export const BoardContainer = (): React.JSX.Element | null => {

return (
(!isBoardEmpty && current && (
<BoardContainerComp expanded={expanded} minimized={minimized} ref={boardContainerRef}>
<BoardContainerComp $expanded={expanded} $minimized={minimized} ref={boardContainerRef}>
<Board
data-testid="NewItemContainer"
background={'gray6'}
crossAlignment="unset"
expanded={expanded}
$expanded={expanded}
ref={boardRef}
width={currentBoardSizeAndPosition.width}
height={currentBoardSizeAndPosition.height}
Expand Down Expand Up @@ -444,7 +443,7 @@ export const BoardContainer = (): React.JSX.Element | null => {
<Divider style={{ height: '0.125rem' }} />
<BoardDetailContainer takeAvailableSpace>
{map(boards, (b) => (
<AppBoard key={b.id} board={b} />
<AppBoard key={b.id} $board={b} />
rodleyorosa marked this conversation as resolved.
Show resolved Hide resolved
))}
</BoardDetailContainer>
</ResizableContainer>
Expand Down
21 changes: 10 additions & 11 deletions src/shell/boards/board-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';

import type { RowProps } from '@zextras/carbonio-design-system';
import { Container, Icon, IconButton, Row, Text, Tooltip } from '@zextras/carbonio-design-system';
import type { SimpleInterpolation } from 'styled-components';
import styled, { css } from 'styled-components';

import { closeBoard, setCurrentBoard, useBoardStore } from '../../store/boards';
import { getT } from '../../store/i18n/hooks';
import './board-tab.css';

const TabContainer = styled(Row)<RowProps & { active: boolean }>`
const TabContainer = styled(Row)<RowProps & { $active: boolean }>`
container-type: inline-size;
container-name: tab;
max-width: calc(3rem + 15ch);
Expand All @@ -26,15 +25,15 @@ const TabContainer = styled(Row)<RowProps & { active: boolean }>`
cursor: pointer;
height: 1.75rem;
user-select: none;
background-color: ${({ theme, active }): string =>
active ? theme.palette.gray3.regular : theme.palette.gray5.regular};
background-color: ${({ theme, $active }): string =>
$active ? theme.palette.gray3.regular : theme.palette.gray5.regular};
gap: 0.25rem;
border-radius: 0.25rem;
margin-left: 0.25rem;
margin-right: 0.25rem;
overflow: hidden;
${({ active }): SimpleInterpolation =>
active &&
${({ $active }): ReturnType<typeof css> | false =>
$active &&
css`
min-width: calc(3rem + 15ch);
`}
Expand All @@ -48,9 +47,9 @@ const TabIcon = styled(Icon)`
min-width: 1.5rem;
`;

const CustomText = styled(Text)<{ overflowing: boolean }>`
${({ overflowing }): SimpleInterpolation =>
overflowing &&
const CustomText = styled(Text)<{ $overflowing: boolean }>`
${({ $overflowing }: { $overflowing: boolean }): ReturnType<typeof css> | false =>
rodleyorosa marked this conversation as resolved.
Show resolved Hide resolved
$overflowing &&
css`
mask-image: linear-gradient(90deg, #000 60%, transparent);
`}
Expand Down Expand Up @@ -120,15 +119,15 @@ export const AppBoardTab: FC<{ id: string; icon: string; title: string; firstTab
onClick={onClick}
data-testid={`board-tab-${id}`}
padding={{ horizontal: 'extrasmall' }}
active={current === id}
$active={current === id}
>
<TabIcon icon={icon} size="large" />
<Tooltip label={title} placement="top" maxWidth="700px" triggerRef={textRef}>
<CustomText
size="medium"
weight="regular"
color={current === id ? 'text' : 'secondary'}
overflowing={textOverflowing}
$overflowing={textOverflowing}
className="tab-text"
>
{title}
Expand Down
14 changes: 7 additions & 7 deletions src/shell/boards/board.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { BoardProvider, useBoardStore } from '../../store/boards';
import type { BoardView } from '../../types/apps';
import type { Board } from '../../types/boards';

const BoardContainer = styled.div<{ show: boolean }>`
display: ${(props): string => (props.show ? 'block' : 'none')};
const BoardContainer = styled.div<{ $show: boolean }>`
display: ${(props): string => (props.$show ? 'block' : 'none')};
height: 100%;
width: 100%;
overflow-y: auto;
Expand Down Expand Up @@ -49,18 +49,18 @@ const BoardViewComponent = ({
</AppContextProvider>
);

export const AppBoard = ({ board }: { board: Board }): React.JSX.Element => {
export const AppBoard = ({ $board }: { $board: Board }): React.JSX.Element => {
rodleyorosa marked this conversation as resolved.
Show resolved Hide resolved
const current = useBoardStore((s) => s.current);
const boardViews = useAppStore((s) => s.views.board);
const boardView = useMemo(
() => find(boardViews, (v) => v.id === board.boardViewId),
[board.boardViewId, boardViews]
() => find(boardViews, (v) => v.id === $board.boardViewId),
[$board.boardViewId, boardViews]
);

return (
<BoardContainer show={current === board.id}>
<BoardContainer $show={current === $board.id}>
{boardView ? (
<BoardViewComponent view={boardView} boardId={board.id} />
<BoardViewComponent view={boardView} boardId={$board.id} />
) : (
<Container orientation={'row'} mainAlignment={'center'}>
<p>Missing Board View</p>
Expand Down
5 changes: 2 additions & 3 deletions src/shell/boards/resizable-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import React, { useMemo, useRef } from 'react';

import type { ContainerProps } from '@zextras/carbonio-design-system';
import { Container } from '@zextras/carbonio-design-system';
import type { SimpleInterpolation } from 'styled-components';
import styled, { css } from 'styled-components';

import type { Border } from '../hooks/useResize';
Expand Down Expand Up @@ -59,8 +58,8 @@ const BorderWithResize = styled.div<
cursor: ${({ $cursor }): CSSProperties['cursor'] => $cursor};
width: ${({ $width }): string => $width};
height: ${({ $height }): string => $height};
${({ $position }): SimpleInterpolation => $position};
${({ $translateTransform }): SimpleInterpolation =>
${({ $position }): BorderWithResizeProps['$position'] => $position};
${({ $translateTransform }): ReturnType<typeof css> | undefined | string =>
($translateTransform?.x || $translateTransform?.y) &&
css`
transform: translate(${$translateTransform?.x ?? 0}, ${$translateTransform?.y ?? 0});
Expand Down
6 changes: 3 additions & 3 deletions src/shell/shell-secondary-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import type { AppRoute } from '../types/apps';
import { useUtilityBarStore } from '../utility-bar/store';
import { checkRoute } from '../utility-bar/utils';

const SidebarContainer = styled(Container)<ContainerProps & { sidebarIsOpen?: boolean }>`
const SidebarContainer = styled(Container)<ContainerProps & { $sidebarIsOpen?: boolean }>`
min-width: 3rem;
max-width: 19.625rem;
width: ${({ sidebarIsOpen }): number => (sidebarIsOpen ? 19.625 : 3)}rem;
width: ${({ $sidebarIsOpen }): number => ($sidebarIsOpen ? 19.625 : 3)}rem;
transition: width 300ms;
overflow-x: hidden;
`;
Expand All @@ -51,7 +51,7 @@ const ShellSecondaryBarComponent: FC<{ activeRoute: AppRoute }> = ({ activeRoute
<>
<SidebarContainer
data-testid="SideSecondaryBarContainer"
sidebarIsOpen={isOpen}
$sidebarIsOpen={isOpen}
role="menu"
height="fill"
orientation="vertical"
Expand Down