File tree Expand file tree Collapse file tree 5 files changed +107
-35
lines changed
src/frontend/apps/impress/src/features Expand file tree Collapse file tree 5 files changed +107
-35
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to
11
11
### Added
12
12
13
13
- ✨(api) add API route to fetch document content #1206
14
+ - ✨(frontend) display pin on top of doc emoji or default icon #1358
14
15
15
16
### Changed
16
17
Original file line number Diff line number Diff line change 1
1
import { useTranslation } from 'react-i18next' ;
2
+ import { css } from 'styled-components' ;
2
3
3
- import { Text , TextType } from '@/components' ;
4
+ import { Box , Text , TextType } from '@/components' ;
5
+ import { useCunninghamTheme } from '@/cunningham' ;
6
+
7
+ import Pin from '../assets/pin.svg' ;
4
8
5
9
type DocIconProps = TextType & {
6
10
emoji ?: string | null ;
7
11
defaultIcon : React . ReactNode ;
12
+ isPinned ?: boolean ;
8
13
} ;
9
14
10
15
export const DocIcon = ( {
11
16
emoji,
12
17
defaultIcon,
18
+ isPinned = false ,
13
19
$size = 'sm' ,
14
20
$variation = '1000' ,
15
21
$weight = '400' ,
16
22
...textProps
17
23
} : DocIconProps ) => {
18
24
const { t } = useTranslation ( ) ;
19
-
20
- if ( ! emoji ) {
21
- return < > { defaultIcon } </ > ;
22
- }
25
+ const { colorsTokens } = useCunninghamTheme ( ) ;
23
26
24
27
return (
25
- < Text
26
- { ... textProps }
27
- $size = { $size }
28
- $variation = { $variation }
29
- $weight = { $weight }
30
- aria-hidden = "true"
31
- aria-label = { t ( 'Document emoji icon' ) }
28
+ < Box
29
+ $css = { css `
30
+ display : grid;
31
+ grid-template-columns : 1 fr ;
32
+ grid-template-rows : 1 fr ;
33
+ place-items : center;
34
+ ` }
32
35
>
33
- { emoji }
34
- </ Text >
36
+ < Box
37
+ $css = { css `
38
+ grid-column-start : 1 ;
39
+ grid-row-start : 1 ;
40
+ ` }
41
+ >
42
+ { ! emoji ? (
43
+ < > { defaultIcon } </ >
44
+ ) : (
45
+ < Text
46
+ { ...textProps }
47
+ $size = { $size }
48
+ $variation = { $variation }
49
+ $weight = { $weight }
50
+ aria-hidden = "true"
51
+ aria-label = { t ( 'Document emoji icon' ) }
52
+ >
53
+ { emoji }
54
+ </ Text >
55
+ ) }
56
+ </ Box >
57
+ { isPinned && (
58
+ < Box
59
+ $css = { css `
60
+ grid-column-start : 1 ;
61
+ grid-row-start : 1 ;
62
+ transform : translate (25% , -25% );
63
+ ` }
64
+ >
65
+ < Pin
66
+ color = { colorsTokens [ 'primary-500' ] }
67
+ aria-hidden = "true"
68
+ aria-label = { t ( 'Pin document icon' ) }
69
+ />
70
+ </ Box >
71
+ ) }
72
+ </ Box >
35
73
) ;
36
74
} ;
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { useCunninghamTheme } from '@/cunningham';
7
7
import { Doc , getEmojiAndTitle , useTrans } from '@/docs/doc-management' ;
8
8
import { useResponsiveStore } from '@/stores' ;
9
9
10
- import PinnedDocumentIcon from '../assets/pinned-document.svg' ;
11
10
import SimpleFileIcon from '../assets/simple-document.svg' ;
12
11
13
12
import { DocIcon } from './DocIcon' ;
@@ -60,25 +59,18 @@ export const SimpleDocItem = ({
60
59
$padding = { `${ spacingsTokens [ '3xs' ] } 0` }
61
60
data-testid = { isPinned ? `doc-pinned-${ doc . id } ` : undefined }
62
61
>
63
- { isPinned ? (
64
- < PinnedDocumentIcon
65
- aria-hidden = "true"
66
- aria-label = { t ( 'Pin document icon' ) }
67
- color = { colorsTokens [ 'primary-500' ] }
68
- />
69
- ) : (
70
- < DocIcon
71
- emoji = { emoji }
72
- defaultIcon = {
73
- < SimpleFileIcon
74
- aria-hidden = "true"
75
- aria-label = { t ( 'Simple document icon' ) }
76
- color = { colorsTokens [ 'primary-500' ] }
77
- />
78
- }
79
- $size = "25px"
80
- />
81
- ) }
62
+ < DocIcon
63
+ emoji = { emoji }
64
+ isPinned = { isPinned }
65
+ defaultIcon = {
66
+ < SimpleFileIcon
67
+ aria-hidden = "true"
68
+ aria-label = { t ( 'Simple document icon' ) }
69
+ color = { colorsTokens [ 'primary-500' ] }
70
+ />
71
+ }
72
+ $size = "25px"
73
+ />
82
74
</ Box >
83
75
< Box $justify = "center" $overflow = "auto" >
84
76
< Text
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export const LeftPanelFavoriteItem = ({ doc }: LeftPanelFavoriteItemProps) => {
54
54
$css = "overflow: auto;"
55
55
aria-label = { `${ doc . title } , ${ t ( 'Updated' ) } ${ DateTime . fromISO ( doc . updated_at ) . toRelative ( ) } ` }
56
56
>
57
- < SimpleDocItem showAccesses doc = { doc } />
57
+ < SimpleDocItem showAccesses doc = { doc } isPinned = { true } />
58
58
</ StyledLink >
59
59
< div className = "pinned-actions" >
60
60
< DocsGridActions doc = { doc } openShareModal = { shareModal . open } />
You can’t perform that action at this time.
0 commit comments