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
1111### Added
1212
1313- ✨(api) add API route to fetch document content #1206
14+ - ✨(frontend) display pin on top of doc emoji or default icon #1358
1415
1516### Changed
1617
Original file line number Diff line number Diff line change 11import { useTranslation } from 'react-i18next' ;
2+ import { css } from 'styled-components' ;
23
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' ;
48
59type DocIconProps = TextType & {
610 emoji ?: string | null ;
711 defaultIcon : React . ReactNode ;
12+ isPinned ?: boolean ;
813} ;
914
1015export const DocIcon = ( {
1116 emoji,
1217 defaultIcon,
18+ isPinned = false ,
1319 $size = 'sm' ,
1420 $variation = '1000' ,
1521 $weight = '400' ,
1622 ...textProps
1723} : DocIconProps ) => {
1824 const { t } = useTranslation ( ) ;
19-
20- if ( ! emoji ) {
21- return < > { defaultIcon } </ > ;
22- }
25+ const { colorsTokens } = useCunninghamTheme ( ) ;
2326
2427 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+ ` }
3235 >
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 >
3573 ) ;
3674} ;
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ import { useCunninghamTheme } from '@/cunningham';
77import { Doc , getEmojiAndTitle , useTrans } from '@/docs/doc-management' ;
88import { useResponsiveStore } from '@/stores' ;
99
10- import PinnedDocumentIcon from '../assets/pinned-document.svg' ;
1110import SimpleFileIcon from '../assets/simple-document.svg' ;
1211
1312import { DocIcon } from './DocIcon' ;
@@ -60,25 +59,18 @@ export const SimpleDocItem = ({
6059 $padding = { `${ spacingsTokens [ '3xs' ] } 0` }
6160 data-testid = { isPinned ? `doc-pinned-${ doc . id } ` : undefined }
6261 >
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+ />
8274 </ Box >
8375 < Box $justify = "center" $overflow = "auto" >
8476 < Text
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export const LeftPanelFavoriteItem = ({ doc }: LeftPanelFavoriteItemProps) => {
5454 $css = "overflow: auto;"
5555 aria-label = { `${ doc . title } , ${ t ( 'Updated' ) } ${ DateTime . fromISO ( doc . updated_at ) . toRelative ( ) } ` }
5656 >
57- < SimpleDocItem showAccesses doc = { doc } />
57+ < SimpleDocItem showAccesses doc = { doc } isPinned = { true } />
5858 </ StyledLink >
5959 < div className = "pinned-actions" >
6060 < DocsGridActions doc = { doc } openShareModal = { shareModal . open } />
You can’t perform that action at this time.
0 commit comments