Skip to content

Commit

Permalink
Merge pull request #3596 from omnivore-app/fix/web-layout-fixes
Browse files Browse the repository at this point in the history
Small layout fixes for mobile
  • Loading branch information
jacksonh authored Feb 29, 2024
2 parents 81d0648 + 34ee75c commit a743775
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 26 deletions.
14 changes: 14 additions & 0 deletions packages/api/src/jobs/ai-summarize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { libraryItemRepository } from '../repository/library_item'
import { htmlToMarkdown } from '../utils/parser'
import { AISummary } from '../entity/AISummary'
import { LibraryItemState } from '../entity/library_item'
import { getAISummary } from '../services/ai-summaries'

export interface AISummarizeJobData {
userId: string
Expand Down Expand Up @@ -35,6 +36,19 @@ export const aiSummarize = async (jobData: AISummarizeJobData) => {
return
}

const existingSummary = await getAISummary({
userId: jobData.userId,
idx: 'latest',
libraryItemId: jobData.libraryItemId,
})

if (existingSummary) {
logger.info(
`Library item already has a summary: ${jobData.libraryItemId}`
)
return
}

const llm = new ChatOpenAI({
configuration: {
apiKey: process.env.OPENAI_API_KEY,
Expand Down
3 changes: 3 additions & 0 deletions packages/web/components/elements/FormElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const FormInput = styled('input', {
'&:focus': {
outline: 'none',
},
'@mdDown': {
pl: '5px',
},
})

export const FormLabel = styled('label', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ export function LibraryGridCard(props: LinkedItemCardProps): JSX.Element {
overflow: 'hidden',
cursor: 'pointer',
'@media (max-width: 930px)': {
// m: '15px',
width: 'calc(100% - 30px)',
},
'@mdDown': {
width: '100%',
},
}}
alignment="start"
distribution="start"
Expand Down
10 changes: 5 additions & 5 deletions packages/web/components/templates/homeFeed/FetchItemsError.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VStack } from '../../elements/LayoutPrimitives'
import { Box, SpanBox, VStack } from '../../elements/LayoutPrimitives'
import { StyledText } from '../../elements/StyledText'
import { ErrorSlothIcon } from '../../elements/icons/ErrorSlothIcon'
import { DEFAULT_HEADER_HEIGHT } from './HeaderSpacer'
Expand All @@ -13,6 +13,7 @@ export const FetchItemsError = (): JSX.Element => {
width: '100%',
height: '100%',
pb: '100px',
px: '30px',
minHeight: `calc(100vh - ${DEFAULT_HEADER_HEIGHT})`,
}}
>
Expand All @@ -30,16 +31,15 @@ export const FetchItemsError = (): JSX.Element => {
>
Something has gone wrong.
</StyledText>
<StyledText
<SpanBox
css={{
display: 'flex',
marginBlockStart: '0px',
marginBlockEnd: '0px',
fontSize: '15px',
lineHeight: '125%',
fontFamily: '$inter',
color: '$thTextSubtle2',
whiteSpace: 'nowrap',
textAlign: 'center',
}}
>
We have encountered unexpected problems.{' '}
Expand All @@ -50,7 +50,7 @@ export const FetchItemsError = (): JSX.Element => {
>
Get help
</a>
</StyledText>
</SpanBox>
</VStack>
)
}
43 changes: 27 additions & 16 deletions packages/web/components/templates/homeFeed/LibraryHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const headerControlWidths = (
return {
width: '95%',
'@mdDown': {
padding: '15px',
width: '100%',
},
'@media (min-width: 930px)': {
Expand Down Expand Up @@ -135,18 +134,26 @@ function LargeHeaderLayout(props: LibraryHeaderProps): JSX.Element {
}

const HeaderControls = (props: LibraryHeaderProps): JSX.Element => {
const [searchBoxFocused, setSearchBoxFocused] = useState(false)

return (
<>
<SpanBox
css={{
display: 'none',
'@mdDown': { display: 'flex' },
}}
>
<MenuHeaderButton {...props} />
</SpanBox>
{!searchBoxFocused && (
<SpanBox
css={{
display: 'none',
'@mdDown': { display: 'flex' },
}}
>
<MenuHeaderButton {...props} />
</SpanBox>
)}

<SearchBox {...props} />
<SearchBox
{...props}
searchBoxFocused={searchBoxFocused}
setSearchBoxFocused={setSearchBoxFocused}
/>

<SpanBox css={{ display: 'flex', ml: 'auto', gap: '10px' }}>
{userHasFeature(props.viewer, 'ai-summaries') && (
Expand Down Expand Up @@ -243,9 +250,13 @@ export function MenuHeaderButton(props: MenuHeaderButtonProps): JSX.Element {
)
}

export function SearchBox(props: LibraryHeaderProps): JSX.Element {
type SearchBoxProps = LibraryHeaderProps & {
searchBoxFocused: boolean
setSearchBoxFocused: (show: boolean) => void
}

export function SearchBox(props: SearchBoxProps): JSX.Element {
const inputRef = useRef<HTMLInputElement | null>(null)
const [focused, setFocused] = useState(false)
const [searchTerm, setSearchTerm] = useState(props.searchTerm ?? '')

useEffect(() => {
Expand All @@ -272,7 +283,7 @@ export function SearchBox(props: LibraryHeaderProps): JSX.Element {
maxWidth: '521px',
bg: '$thLibrarySearchbox',
borderRadius: '6px',
boxShadow: focused
boxShadow: props.searchBoxFocused
? 'none'
: '0 1px 3px 0 rgba(0, 0, 0, 0.1),0 1px 2px 0 rgba(0, 0, 0, 0.06);',
}}
Expand Down Expand Up @@ -306,7 +317,7 @@ export function SearchBox(props: LibraryHeaderProps): JSX.Element {
alignment="center"
distribution="start"
css={{
border: focused
border: props.searchBoxFocused
? '2px solid $searchActiveOutline'
: '2px solid transparent',
borderTopRightRadius: '6px',
Expand All @@ -331,10 +342,10 @@ export function SearchBox(props: LibraryHeaderProps): JSX.Element {
placeholder="Search keywords or labels"
onFocus={(event) => {
event.target.select()
setFocused(true)
props.setSearchBoxFocused(true)
}}
onBlur={() => {
setFocused(false)
props.setSearchBoxFocused(false)
}}
onChange={(event) => {
setSearchTerm(event.target.value)
Expand Down
23 changes: 21 additions & 2 deletions packages/web/components/templates/homeFeed/MultiSelectControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const MultiSelectControls = (props: LibraryHeaderProps): JSX.Element => {
const [hoverColor, setHoverColor] = useState<string>(
theme.colors.thTextContrast2.toString()
)
const compact = false

return (
<Box
Expand All @@ -45,7 +44,7 @@ export const MultiSelectControls = (props: LibraryHeaderProps): JSX.Element => {
css={{
width: '100%',
height: '100%',
pr: compact ? '5px' : '10px',
pr: '10px',
}}
onClick={(e) => {
e.preventDefault()
Expand Down Expand Up @@ -81,17 +80,37 @@ export const MultiSelectControls = (props: LibraryHeaderProps): JSX.Element => {
border: '2px solid transparent',
width: '100%',
height: '100%',
'@mdDown': {
pl: '5px',
},
}}
>
<SpanBox
css={{
display: 'flex',
fontSize: '14px',
fontFamily: '$display',
marginRight: 'auto',
'@mdDown': {
display: 'none',
},
}}
>
{props.numItemsSelected} items selected
</SpanBox>
<SpanBox
css={{
display: 'none',
fontSize: '14px',
fontFamily: '$display',
marginRight: 'auto',
'@mdDown': {
display: 'flex',
},
}}
>
{props.numItemsSelected} items
</SpanBox>
<ArchiveButton {...props} />
<AddLabelsButton setShowLabelsModal={setShowLabelsModal} />
<RemoveItemsButton setShowConfirmDelete={setShowConfirmDelete} />
Expand Down
25 changes: 23 additions & 2 deletions packages/web/components/templates/homeFeed/TLDRLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ export function TLDRLayout(props: TLDRLayoutProps): JSX.Element {
{props.isValidating && props.items.length == 0 && <TopBarProgress />}

{props.items.map((item) => {
const source = siteName(
const sourceName = siteName(
item.node.originalArticleUrl,
item.node.url,
item.node.siteName
)
const source =
sourceName == item.node.author ? undefined : item.node.author

return (
<VStack key={`tldr-${item.node.id}`} css={{ gap: '10px' }}>
<HStack
Expand Down Expand Up @@ -96,6 +99,12 @@ export function TLDRLayout(props: TLDRLayoutProps): JSX.Element {
display: 'flex',
fontFamily: '$inter',
fontSize: '16px',
maxWidth: '150px',
maxLines: '1',
textOverflow: 'ellipsis',
'@mdDown': {
fontSize: '12px',
},
}}
>
{item.node.siteName}
Expand All @@ -104,9 +113,14 @@ export function TLDRLayout(props: TLDRLayoutProps): JSX.Element {
{source && item.node.author && (
<SpanBox
css={{
maxLines: '1',
display: 'flex',
fontFamily: '$inter',
fontSize: '16px',
maxWidth: '150px',
textOverflow: 'ellipsis',
'@mdDown': {
fontSize: '12px',
},
}}
>
Expand All @@ -118,6 +132,12 @@ export function TLDRLayout(props: TLDRLayoutProps): JSX.Element {
display: 'flex',
fontFamily: '$inter',
fontSize: '16px',
maxWidth: '120px',
maxLines: '1',
textOverflow: 'ellipsis',
'@mdDown': {
fontSize: '12px',
},
}}
>
{item.node.author}
Expand Down Expand Up @@ -145,6 +165,7 @@ export function TLDRLayout(props: TLDRLayoutProps): JSX.Element {
fontFamily: '$inter',
fontWeight: '700',
fontSize: '20px',
wordBreak: 'break-all',
textDecoration: 'underline',
a: {
color: '$thTLDRText',
Expand Down

0 comments on commit a743775

Please sign in to comment.