Skip to content

Commit e729d45

Browse files
committed
save
1 parent 2b67aa7 commit e729d45

File tree

9 files changed

+129
-93
lines changed

9 files changed

+129
-93
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const StyledButton = styled(Button)<StyledButtonProps>`
3131
font-weight: 500;
3232
font-size: 0.938rem;
3333
padding: 0;
34-
${({ $css }) => $css};
34+
border-radius: 4px;
3535
&:hover {
3636
background-color: var(
3737
--c--components--button--primary-text--background--color-hover
@@ -41,6 +41,7 @@ const StyledButton = styled(Button)<StyledButtonProps>`
4141
box-shadow: 0 0 0 2px var(--c--theme--colors--primary-400);
4242
border-radius: 4px;
4343
}
44+
${({ $css }) => $css};
4445
`;
4546

4647
export interface DropButtonProps {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Icon = ({
1313
iconName,
1414
disabled,
1515
variant = 'outlined',
16-
$variation,
16+
$variation = 'text',
1717
...textProps
1818
}: IconProps) => {
1919
const hasLabel = 'aria-label' in textProps || 'aria-labelledby' in textProps;
@@ -41,15 +41,19 @@ type IconOptionsProps = TextType & {
4141
isHorizontal?: boolean;
4242
};
4343

44-
export const IconOptions = ({ isHorizontal, ...props }: IconOptionsProps) => {
44+
export const IconOptions = ({
45+
isHorizontal,
46+
$css,
47+
...props
48+
}: IconOptionsProps) => {
4549
return (
4650
<Icon
47-
{...props}
4851
iconName={isHorizontal ? 'more_horiz' : 'more_vert'}
4952
$css={css`
5053
user-select: none;
51-
${props.$css}
54+
${$css}
5255
`}
56+
{...props}
5357
/>
5458
);
5559
};

src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-inline-content/Interlinking/InterlinkingLinkInlineContent.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable react-hooks/rules-of-hooks */
22
import { createReactInlineContentSpec } from '@blocknote/react';
33
import { useRouter } from 'next/router';
4-
import { useEffect } from 'react';
4+
import { useEffect, useRef } from 'react';
55
import { css } from 'styled-components';
66

77
import { BoxButton, Text } from '@/components';
@@ -28,9 +28,16 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec(
2828
{
2929
render: ({ inlineContent, updateInlineContent }) => {
3030
const { data: doc } = useDoc({ id: inlineContent.props.docId });
31+
const lastUpdatedTitleRef = useRef<string | null>(null);
3132

3233
useEffect(() => {
33-
if (doc?.title && doc.title !== inlineContent.props.title) {
34+
if (
35+
doc?.title &&
36+
doc.title !== inlineContent.props.title &&
37+
lastUpdatedTitleRef.current !== doc.title
38+
) {
39+
lastUpdatedTitleRef.current = doc.title;
40+
3441
updateInlineContent({
3542
type: 'interlinkingLinkInline',
3643
props: {
@@ -66,7 +73,7 @@ const LinkSelected = ({ url, title }: LinkSelectedProps) => {
6673
onClick={handleClick}
6774
draggable="false"
6875
$css={css`
69-
display: inline;
76+
display: contents;
7077
padding: 0.1rem 0.4rem;
7178
border-radius: 4px;
7279
& svg {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const BoutonShare = ({
7676

7777
return (
7878
<Button
79-
color="tertiary-text"
79+
color="primary-text"
8080
onClick={open}
8181
size="medium"
8282
disabled={isDisabled}

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ const DocTitleEmojiPicker = ({ doc }: DocTitleProps) => {
5555
const { colorsTokens } = useCunninghamTheme();
5656
const { emoji } = getEmojiAndTitle(doc.title ?? '');
5757

58+
if (!emoji) {
59+
return null;
60+
}
61+
5862
return (
59-
<Tooltip content={t('Document emoji')} aria-hidden={true} placement="top">
63+
<Tooltip
64+
content={t('Edit document emoji')}
65+
aria-hidden={true}
66+
placement="top"
67+
>
6068
<Box
6169
$css={css`
6270
padding: 4px;
@@ -70,11 +78,17 @@ const DocTitleEmojiPicker = ({ doc }: DocTitleProps) => {
7078
`}
7179
>
7280
<DocIcon
81+
buttonProps={{
82+
$width: '32px',
83+
$height: '32px',
84+
$justify: 'space-between',
85+
$align: 'center',
86+
}}
7387
withEmojiPicker={doc.abilities.partial_update}
7488
docId={doc.id}
7589
title={doc.title}
7690
emoji={emoji}
77-
$size="25px"
91+
$size="23px"
7892
defaultIcon={
7993
<SimpleFileIcon
8094
width="25px"
@@ -94,7 +108,6 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
94108
const { isDesktop } = useResponsiveStore();
95109
const { t } = useTranslation();
96110
const { colorsTokens } = useCunninghamTheme();
97-
const { spacingsTokens } = useCunninghamTheme();
98111
const { isTopRoot } = useDocUtils(doc);
99112
const { untitledDocument } = useTrans();
100113
const { emoji, titleWithoutEmoji } = getEmojiAndTitle(doc.title ?? '');
@@ -139,19 +152,9 @@ const DocTitleInput = ({ doc }: DocTitleProps) => {
139152
className="--docs--doc-title"
140153
$direction="row"
141154
$align="center"
142-
$gap={spacingsTokens['xs']}
155+
$gap="4px"
143156
$minHeight="40px"
144157
>
145-
{isTopRoot && (
146-
<SimpleFileIcon
147-
width="25px"
148-
height="25px"
149-
aria-hidden="true"
150-
aria-label={t('Simple document icon')}
151-
color={colorsTokens['primary-500']}
152-
style={{ flexShrink: '0' }}
153-
/>
154-
)}
155158
{!isTopRoot && <DocTitleEmojiPicker doc={doc} />}
156159

157160
<Tooltip content={t('Rename')} aria-hidden={true} placement="top">

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

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
6060
const selectHistoryModal = useModal();
6161
const modalShare = useModal();
6262

63-
const { isSmallMobile, isDesktop } = useResponsiveStore();
63+
const { isSmallMobile, isMobile } = useResponsiveStore();
6464
const copyDocLink = useCopyDocLink(doc.id);
6565
const { mutate: duplicateDoc } = useDuplicateDoc({
6666
onSuccess: (data) => {
@@ -90,28 +90,20 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
9090
const { updateDocEmoji } = useDocTitleUpdate();
9191

9292
const options: DropdownMenuOption[] = [
93-
...(isSmallMobile
94-
? [
95-
{
96-
label: t('Share'),
97-
icon: 'group',
98-
callback: modalShare.open,
99-
},
100-
{
101-
label: t('Export'),
102-
icon: 'download',
103-
callback: () => {
104-
setIsModalExportOpen(true);
105-
},
106-
show: !!ModalExport,
107-
},
108-
{
109-
label: t('Copy link'),
110-
icon: 'add_link',
111-
callback: copyDocLink,
112-
},
113-
]
114-
: []),
93+
{
94+
label: t('Share'),
95+
icon: 'group',
96+
callback: modalShare.open,
97+
show: isSmallMobile,
98+
},
99+
{
100+
label: t('Export'),
101+
icon: 'download',
102+
callback: () => {
103+
setIsModalExportOpen(true);
104+
},
105+
show: !!ModalExport && isSmallMobile,
106+
},
115107
{
116108
label: doc.is_favorite ? t('Unpin') : t('Pin'),
117109
icon: 'push_pin',
@@ -124,25 +116,38 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
124116
},
125117
testId: `docs-actions-${doc.is_favorite ? 'unpin' : 'pin'}-${doc.id}`,
126118
},
127-
...(emoji && doc.abilities.partial_update && !isTopRoot
128-
? [
129-
{
130-
label: t('Remove emoji'),
131-
icon: 'emoji_emotions',
132-
callback: () => {
133-
updateDocEmoji(doc.id, doc.title ?? '', '');
134-
},
135-
},
136-
]
137-
: []),
138119
{
139120
label: t('Version history'),
140121
icon: 'history',
141122
disabled: !doc.abilities.versions_list,
142123
callback: () => {
143124
selectHistoryModal.open();
144125
},
145-
show: isDesktop,
126+
show: !isMobile,
127+
showSeparator: isTopRoot ? true : false,
128+
},
129+
{
130+
label: t('Remove emoji'),
131+
icon: 'emoji_emotions',
132+
callback: () => {
133+
updateDocEmoji(doc.id, doc.title ?? '', '');
134+
},
135+
showSeparator: true,
136+
show: !!emoji && doc.abilities.partial_update && !isTopRoot,
137+
},
138+
{
139+
label: t('Add emoji'),
140+
icon: 'emoji_emotions',
141+
callback: () => {
142+
updateDocEmoji(doc.id, doc.title ?? '', '📄');
143+
},
144+
showSeparator: true,
145+
show: !emoji && doc.abilities.partial_update && !isTopRoot,
146+
},
147+
{
148+
label: t('Copy link'),
149+
icon: 'add_link',
150+
callback: copyDocLink,
146151
},
147152
{
148153
label: t('Copy as {{format}}', { format: 'Markdown' }),
@@ -158,6 +163,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
158163
void copyCurrentEditorToClipboard('html');
159164
},
160165
show: isFeatureFlagActivated('CopyAsHTML'),
166+
showSeparator: true,
161167
},
162168
{
163169
label: t('Duplicate'),
@@ -170,6 +176,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
170176
canSave: doc.abilities.partial_update,
171177
});
172178
},
179+
showSeparator: true,
173180
},
174181
{
175182
label: isChild ? t('Delete sub-document') : t('Delete document'),
@@ -224,25 +231,22 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
224231
aria-label={t('Export the document')}
225232
/>
226233
)}
227-
<DropdownMenu options={options} label={t('Open the document options')}>
228-
<IconOptions
229-
aria-hidden="true"
230-
isHorizontal
231-
$theme="primary"
232-
$padding={{ all: 'xs' }}
233-
$css={css`
234-
border-radius: 4px;
235-
&:hover {
236-
background-color: ${colorsTokens['greyscale-100']};
237-
}
238-
${isSmallMobile
239-
? css`
240-
padding: 10px;
241-
border: 1px solid ${colorsTokens['greyscale-300']};
242-
`
243-
: ''}
244-
`}
245-
/>
234+
<DropdownMenu
235+
options={options}
236+
label={t('Open the document options')}
237+
buttonCss={css`
238+
padding: ${spacingsTokens['xs']};
239+
&:hover {
240+
background-color: ${colorsTokens['greyscale-100']};
241+
}
242+
${isSmallMobile
243+
? css`
244+
border: 1px solid ${colorsTokens['greyscale-300']};
245+
`
246+
: ''}
247+
`}
248+
>
249+
<IconOptions aria-hidden="true" isHorizontal $theme="primary" />
246250
</DropdownMenu>
247251
</Box>
248252

src/frontend/apps/impress/src/features/docs/doc-management/components/DocIcon.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { MouseEvent, useRef, useState } from 'react';
22
import { createPortal } from 'react-dom';
33

4-
import { BoxButton, Icon, TextType } from '@/components';
4+
import { BoxButton, BoxButtonType, Text, TextType } from '@/components';
55
import { EmojiPicker, emojidata } from '@/docs/doc-editor/';
66

77
import { useDocTitleUpdate } from '../hooks/useDocTitleUpdate';
88

99
type DocIconProps = TextType & {
10+
buttonProps?: BoxButtonType;
1011
emoji?: string | null;
1112
defaultIcon: React.ReactNode;
1213
docId?: string;
@@ -16,6 +17,7 @@ type DocIconProps = TextType & {
1617
};
1718

1819
export const DocIcon = ({
20+
buttonProps,
1921
emoji,
2022
defaultIcon,
2123
$size = 'sm',
@@ -81,21 +83,21 @@ export const DocIcon = ({
8183
ref={iconRef}
8284
onClick={toggleEmojiPicker}
8385
color="tertiary-text"
86+
{...buttonProps}
8487
>
8588
{!emoji ? (
8689
defaultIcon
8790
) : (
88-
<Icon
91+
<Text
8992
{...textProps}
90-
iconName={emoji}
9193
$size={$size}
9294
$variation={$variation}
9395
$weight={$weight}
9496
aria-hidden="true"
9597
data-testid="doc-emoji-icon"
9698
>
9799
{emoji}
98-
</Icon>
100+
</Text>
99101
)}
100102
</BoxButton>
101103
{openEmojiPicker &&

0 commit comments

Comments
 (0)