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

Add inspector view using allotment #2677

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
85bae99
Rebase
jacksonh Oct 9, 2023
ba6e673
Clean up readable interface
jacksonh Aug 21, 2023
6d3367e
Add flexgrow so the notes area doesnt take up too much space
jacksonh Aug 21, 2023
b2a1fac
Add footer for better scrolling on mobile
jacksonh Aug 21, 2023
158c937
Remove scroll box, set scroll on edit item view
jacksonh Aug 21, 2023
e8dcd2d
Improve notebook layout
jacksonh Aug 21, 2023
a66f3e8
Improve inspector buttons on mobile
jacksonh Aug 21, 2023
5c1acb3
Adjust library header
jacksonh Aug 21, 2023
53bb492
More mobile menu cleanup
jacksonh Aug 21, 2023
95c7a99
Set a height on the textarea for notes
jacksonh Aug 21, 2023
12ba6ed
Empty state for the outline view
jacksonh Aug 21, 2023
88d0a35
Add padding on empty state message
jacksonh Aug 21, 2023
486444a
More improvement on mobile inspector view
jacksonh Aug 21, 2023
cdaa8d2
Add some debugging
jacksonh Aug 21, 2023
73b0578
Set document size in CSS and dont use 100vw on child elements
jacksonh Aug 22, 2023
1d1e363
More work on inspector mobile sizing
jacksonh Aug 22, 2023
fa8397f
Improve scrolling and flex on mobile
jacksonh Aug 22, 2023
3678b39
Improve scrolling, show edit info in the inspector
jacksonh Aug 22, 2023
e44dc65
Improve menu animation
jacksonh Aug 22, 2023
d63f377
16pt fonts on forms so iOS doesnt resize
jacksonh Aug 22, 2023
d9f7baf
Sizing for mobile
jacksonh Aug 22, 2023
1366cfa
Allow setting reading progress from the edit info view
jacksonh Aug 22, 2023
32a2d53
Add reading progress percent to info
jacksonh Aug 22, 2023
6d6dfe6
Linter fixes
jacksonh Aug 22, 2023
04f24e2
Improve textbox sizing
jacksonh Aug 22, 2023
55d103a
Scrolling improvements in the inspector
jacksonh Aug 23, 2023
b2ee870
Make the list card more tappable on small screens
jacksonh Aug 23, 2023
3b02fd4
Tweak heights
jacksonh Aug 23, 2023
c3d021f
Add more debugging
jacksonh Aug 23, 2023
d5c7f62
Set the outline from article container to prevent a race on load
jacksonh Aug 23, 2023
348c57a
Improve outline scrolling
jacksonh Aug 23, 2023
fb00ca2
Fix scroll watching now that the reader is in a panel
jacksonh Aug 23, 2023
bdd5419
Remove some debug
jacksonh Aug 23, 2023
f8f3341
Fix background color for highlight on hover notes
jacksonh Aug 25, 2023
dc57358
Increase the z index on the menu so its above all library items
jacksonh Aug 28, 2023
b2dd40b
rebase catch ups
jacksonh Oct 10, 2023
4433748
Better handling of keyboard commands for the inspector views
jacksonh Oct 10, 2023
70e376c
Remove labels from inspector add shortcut hints
jacksonh Oct 10, 2023
74bd631
Improve scrolling from the outline view
jacksonh Oct 10, 2023
18db3e4
Work on reading progress editor
jacksonh Oct 11, 2023
305aa5d
Fix import
jacksonh Nov 3, 2023
1619208
Fix color after rebase
jacksonh Nov 3, 2023
dd55557
Simplify article action menus with split view
jacksonh Nov 3, 2023
05a88ff
Fix after rebase
jacksonh Nov 3, 2023
b5998cb
Update yarn.lock with allotment imports
jacksonh Nov 3, 2023
3875fef
Set separator colour
jacksonh Nov 3, 2023
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
2 changes: 2 additions & 0 deletions packages/web/components/elements/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ export const Button = styled('button', {

},
articleActionIcon: {
display: 'flex',
alignItems: 'center',
bg: 'transparent',
border: 'none',
cursor: 'pointer',
Expand Down
31 changes: 31 additions & 0 deletions packages/web/components/elements/EditLabelChipStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,34 @@ export function EditLabelChipStack(
</SpanBox>
)
}

type ColoredStackProps = {
colors: string[]
}

export const ColoredStack = (props: ColoredStackProps): JSX.Element => {
const colors = useMemo(() => {
if (props.colors.length > 7) {
const set = new Set(props.colors)
return Array.from(set).slice(0, 7)
}
return props.colors
}, [props])

return (
<>
{colors.map((color, idx) => (
<SpanBox
key={`label-color${idx}`}
css={{
marginLeft: -15,
height: '100%',
display: 'inline-flex',
}}
>
<Circle size={14} color={color} weight="fill" />
</SpanBox>
))}
</>
)
}
14 changes: 14 additions & 0 deletions packages/web/components/elements/StyledText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ const textVariants = {
fontSize: '$2',
lineHeight: '1.25',
},
emptyListMessage: {
p: '10px',
mt: '15px',
width: '100%',
fontSize: '13px',
fontFamily: '$inter',
color: '$thTextSubtle',
alignItems: 'center',
justifyContent: 'center',
mb: '100px',
bg: '$thBackground2', // isDark ? '#3D3D3D' : '$thBackground',
borderRadius: '6px',
boxShadow: '0px 4px 4px rgba(33, 33, 33, 0.1)',
},
},
}

Expand Down
39 changes: 39 additions & 0 deletions packages/web/components/elements/icons/LeftPanelToggleIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* eslint-disable functional/no-class */
/* eslint-disable functional/no-this-expression */
import { IconProps } from './IconProps'

import React from 'react'

export class LeftPanelToggleIcon extends React.Component<IconProps> {
render() {
const size = (this.props.size || 26).toString()
const color = (this.props.color || '#2A2A2A').toString()

return (
<svg
width={size}
height={size}
viewBox="0 0 26 26"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<path
d="M4.90039 6.73861C4.90039 6.18607 5.11988 5.65617 5.51058 5.26547C5.90129 4.87477 6.43119 4.65527 6.98372 4.65527H19.4837C20.0363 4.65527 20.5662 4.87477 20.9569 5.26547C21.3476 5.65617 21.5671 6.18607 21.5671 6.73861V19.2386C21.5671 19.7911 21.3476 20.321 20.9569 20.7117C20.5662 21.1024 20.0363 21.3219 19.4837 21.3219H6.98372C6.43119 21.3219 5.90129 21.1024 5.51058 20.7117C5.11988 20.321 4.90039 19.7911 4.90039 19.2386V6.73861Z"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M10.1094 4.65527V21.3219"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</g>
</svg>
)
}
}
67 changes: 67 additions & 0 deletions packages/web/components/elements/icons/OutlineIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable functional/no-class */
/* eslint-disable functional/no-this-expression */
import { IconProps } from './IconProps'

import React from 'react'

export class OutlineIcon extends React.Component<IconProps> {
render() {
const size = (this.props.size || 26).toString()
const color = (this.props.color || '#2A2A2A').toString()

return (
<svg
width={size}
height={size}
viewBox="0 0 25 26"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<path
d="M9.375 6.93164H20.8333"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9.375 13.1816H20.8333"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M9.375 19.4316H20.8333"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M5.20898 6.93164V6.94164"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M5.20898 13.1816V13.1916"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M5.20898 19.4316V19.4416"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</g>
</svg>
)
}
}
32 changes: 32 additions & 0 deletions packages/web/components/elements/icons/TreeDownIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable functional/no-class */
/* eslint-disable functional/no-this-expression */
import { IconProps } from './IconProps'

import React from 'react'

export class TreeDownIcon extends React.Component<IconProps> {
render() {
const size = (this.props.size || 18).toString()
const color = (this.props.color || '#2A2A2A').toString()

return (
<svg
width={size}
height={size}
viewBox="0 0 18 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<path
d="M4.5 6.75L9 11.25L13.5 6.75"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</g>
</svg>
)
}
}
32 changes: 32 additions & 0 deletions packages/web/components/elements/icons/TreeRightIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable functional/no-class */
/* eslint-disable functional/no-this-expression */
import { IconProps } from './IconProps'

import React from 'react'

export class TreeRightIcon extends React.Component<IconProps> {
render() {
const size = (this.props.size || 18).toString()
const color = (this.props.color || '#2A2A2A').toString()

return (
<svg
xmlns="http://www.w3.org/2000/svg"
width={size}
height={size}
viewBox="0 0 18 18"
fill="none"
>
<g>
<path
d="M6.75 13.5L11.25 9L6.75 4.5"
stroke={color}
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
</g>
</svg>
)
}
}
33 changes: 6 additions & 27 deletions packages/web/components/patterns/ArticleNotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import 'react-markdown-editor-lite/lib/index.css'
import throttle from 'lodash/throttle'
import { updateHighlightMutation } from '../../lib/networking/mutations/updateHighlightMutation'
import { Highlight } from '../../lib/networking/fragments/highlightFragment'
import Counter from './MDEditorSavePlugin'
import SavePlugin from './MDEditorSavePlugin'
import { isDarkTheme } from '../../lib/themeUpdater'
import { RcEditorStyles } from './RcEditorStyles'
import { MDEditorSettings, RcEditorStyles } from './RcEditorStyles'

const mdParser = new MarkdownIt()

MdEditor.use(Plugins.TabInsert, {
tabMapValue: 1, // note that 1 means a '\t' instead of ' '.
})

MdEditor.use(Counter)
MdEditor.use(SavePlugin)

type NoteSectionProps = {
targetId: string
Expand Down Expand Up @@ -181,32 +181,11 @@ export function MarkdownNote(props: MarkdownNote): JSX.Element {
ref={editorRef}
value={props.text}
placeholder={props.placeHolder}
view={{ menu: true, md: true, html: false }}
canView={{
menu: true,
md: true,
html: true,
both: false,
fullScreen: false,
hideMenu: false,
}}
plugins={[
'tab-insert',
'header',
'font-bold',
'font-italic',
'font-underline',
'font-strikethrough',
'list-unordered',
'list-ordered',
'block-quote',
'link',
'auto-resize',
'save',
]}
view={MDEditorSettings.view}
canView={MDEditorSettings.canView}
plugins={MDEditorSettings.plugins}
style={{
width: '100%',
height: '180px',
}}
renderHTML={(text: string) => mdParser.render(text)}
onChange={handleEditorChange}
Expand Down
49 changes: 27 additions & 22 deletions packages/web/components/patterns/ArticleSubtitle.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
import { Box, StyledLink } from './../elements/LayoutPrimitives'
import { StyledText } from './../../components/elements/StyledText'
import { formattedLongDate } from './../../lib/dateFormatting'
import { ReadableItem } from '../../lib/networking/queries/useGetLibraryItemsQuery'
import { siteName } from './LibraryCards/LibraryCardStyles'

type SubtitleStyle = 'footnote' | 'shareSubtitle'

type ArticleSubtitleProps = {
href: string
item: ReadableItem
author?: string
style?: SubtitleStyle
hideButton?: boolean
}

export function ArticleSubtitle(props: ArticleSubtitleProps): JSX.Element {
const textStyle = props.style || 'footnote'
const subtitle = articleSubtitle(props.href, props.author)
const subtitle = articleSubtitle(props.item, props.author)

return (
<Box>
<StyledText style={textStyle} css={{ wordBreak: 'break-word' }}>
{subtitle} {subtitle && <span style={{ bottom: 1 }}>• </span>}{' '}
{!props.hideButton && !shouldHideUrl(props.href) && (
<>
<StyledLink
href={props.href}
target="_blank"
rel="noreferrer"
css={{
textDecoration: 'underline',
color: '$grayTextContrast',
}}
>
See original
</StyledLink>
</>
)}
{props.item.originalArticleUrl &&
!shouldHideUrl(props.item.originalArticleUrl) && (
<>
<StyledLink
href={props.item.originalArticleUrl}
target="_blank"
rel="noreferrer"
css={{
textDecoration: 'underline',
color: '$grayTextContrast',
}}
>
See original
</StyledLink>
</>
)}
</StyledText>
</Box>
)
Expand Down Expand Up @@ -76,12 +78,15 @@ function shouldHideUrl(url: string): boolean {
return false
}

function articleSubtitle(url: string, author?: string): string | undefined {
const origin = new URL(url).origin
const hideUrl = shouldHideUrl(url)
function articleSubtitle(
item: ReadableItem,
author?: string
): string | undefined {
const origin = new URL(item.originalArticleUrl).origin
const hideUrl = shouldHideUrl(item.originalArticleUrl)
if (author) {
const auth = `${authoredByText(author)}`
return hideUrl ? auth : `${auth}, ${new URL(url).hostname}`
return hideUrl ? auth : `${auth}, ${siteName(item)}`
} else {
if (hideUrl) {
return undefined
Expand Down
5 changes: 2 additions & 3 deletions packages/web/components/patterns/HighlightBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type PageCoordinates = {
export type HighlightAction =
| 'delete'
| 'create'
| 'comment'
| 'createWithNote'
| 'share'
| 'post'
| 'unshare'
Expand Down Expand Up @@ -172,11 +172,10 @@ function BarContent(props: HighlightBarProps): JSX.Element {
</Button>
</>
)}

<Button
title={props.isNewHighlight ? `Create highlight w/note` : 'Add note'}
style="highlightBarIcon"
onClick={() => props.handleButtonClick('comment')}
onClick={() => props.handleButtonClick('createWithNote')}
onMouseEnter={() => {
setHovered('note')
}}
Expand Down
Loading
Loading