interation

This commit is contained in:
Tom Moor committed 2025-12-06 18:49:48 -05:00
1 parent 074a9020dc
commit 917a3baeb4
7 files changed
+105 -67

No files matched your search

+52 -53
View File
@@ -6,6 +6,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { DocumentIcon } from "outline-icons";
import styled, { css, useTheme } from "styled-components";
import breakpoint from "styled-components-breakpoint";
import EventBoundary from "@shared/components/EventBoundary";
@@ -29,7 +30,6 @@ import { ActionContextProvider } from "~/hooks/useActionContext";
import { useDocumentMenuAction } from "~/hooks/useDocumentMenuAction";
import { ContextMenu } from "./Menu/ContextMenu";
import useStores from "~/hooks/useStores";
import { DocumentIcon } from "outline-icons";
type Props = {
document: Document;
@@ -129,57 +129,57 @@ function DocumentListItem(
{...rest}
{...rovingTabIndex}
>
<Content>
<Heading dir={document.dir}>
{document.icon ? (
<Icon
value={document.icon}
color={document.color ?? undefined}
initial={document.initial}
/>
) : (
<DocumentIcon
color={document.collection?.color ?? theme.textSecondary}
/>
)}
<Title
text={document.titleWithDefault}
highlight={highlight}
dir={document.dir}
/>
{document.isBadgedNew && document.createdBy?.id !== user.id && (
<Badge yellow>{t("New")}</Badge>
)}
{document.isDraft && showDraft && (
<Tooltip content={t("Only visible to you")} placement="top">
<Badge>{t("Draft")}</Badge>
</Tooltip>
)}
{canStar && (
<StarPositioner>
<StarButton document={document} />
</StarPositioner>
)}
{document.isTemplate && showTemplate && (
<Badge primary>{t("Template")}</Badge>
)}
</Heading>
{!queryIsInTitle && (
<ResultContext
text={context}
highlight={highlight ? SEARCH_RESULT_REGEX : undefined}
processResult={replaceResultMarks}
<Flex gap={4} auto>
{document.icon ? (
<Icon
value={document.icon}
color={document.color ?? undefined}
initial={document.initial}
/>
) : (
<DocumentIcon color={theme.textSecondary} />
)}
<DocumentMeta
document={document}
showCollection={showCollection}
showPublished={showPublished}
showParentDocuments={showParentDocuments}
showLastViewed
/>
</Content>
<Content>
<Heading dir={document.dir}>
<Title
text={document.titleWithDefault}
highlight={highlight}
dir={document.dir}
/>
{document.isBadgedNew && document.createdBy?.id !== user.id && (
<Badge yellow>{t("New")}</Badge>
)}
{document.isDraft && showDraft && (
<Tooltip content={t("Only visible to you")} placement="top">
<Badge>{t("Draft")}</Badge>
</Tooltip>
)}
{canStar && (
<StarPositioner>
<StarButton document={document} />
</StarPositioner>
)}
{document.isTemplate && showTemplate && (
<Badge primary>{t("Template")}</Badge>
)}
</Heading>
{!queryIsInTitle && (
<ResultContext
text={context}
highlight={highlight ? SEARCH_RESULT_REGEX : undefined}
processResult={replaceResultMarks}
/>
)}
<DocumentMeta
document={document}
showCollection={showCollection}
showPublished={showPublished}
showParentDocuments={showParentDocuments}
showLastViewed
/>
</Content>
</Flex>
<Actions>
<DocumentMenu
document={document}
@@ -226,7 +226,7 @@ const DocumentLink = styled(Link)<{
}>`
display: flex;
align-items: center;
margin: 10px -8px;
margin: 10px -36px;
padding: 6px 8px;
border-radius: 8px;
max-height: 50vh;
@@ -288,14 +288,13 @@ const Heading = styled.span<{ rtl?: boolean }>`
justify-content: ${(props) => (props.rtl ? "flex-end" : "flex-start")};
align-items: center;
margin-top: 0;
margin-bottom: 0.25em;
margin-bottom: 0.1em;
white-space: nowrap;
color: ${s("text")};
font-family: ${s("fontFamily")};
font-weight: 500;
font-size: 18px;
line-height: 1.2;
margin-left: -28px;
gap: 4px;
`;
+1 -1
View File
@@ -158,7 +158,7 @@ const List = styled.div`
grid-template-columns: repeat(2, minmax(0, 1fr));
padding: 0;
list-style: none;
margin: 16px 0 32px;
margin: 32px 0 32px;
&:empty {
display: none;
+11 -7
View File
@@ -43,13 +43,17 @@ const TabLink = styled(NavLink)`
const Active = styled(m.div)`
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 3px;
width: 100%;
border-radius: 3px;
background: ${s("textSecondary")};
left: -8px;
right: -8px;
border-radius: 12px;
corner-shape: superellipse(1);
background: ${s("sidebarActiveBackground")};
`;
const Content = styled.span`
position: relative;
`;
const transition = {
@@ -77,7 +81,6 @@ const Tab: React.FC<Props> = ({
>
{(match, location) => (
<>
{children}
{match &&
(!exactQueryString ||
isEqual(
@@ -90,6 +93,7 @@ const Tab: React.FC<Props> = ({
transition={transition}
/>
)}
<Content>{children}</Content>
</>
)}
</TabLink>
+5 -5
View File
@@ -6,8 +6,8 @@ import { s } from "@shared/styles";
import useWindowSize from "~/hooks/useWindowSize";
const Nav = styled.nav<{ $shadowVisible?: boolean }>`
border-bottom: 1px solid ${s("divider")};
margin: 12px 0;
margin: -8px -32px 28px;
padding: 0 32px;
overflow-y: auto;
white-space: nowrap;
@@ -41,9 +41,9 @@ const Nav = styled.nav<{ $shadowVisible?: boolean }>`
// items that scroll past can "stick out" the sides of the heading
const Sticky = styled.div`
position: sticky;
top: 54px;
margin: 0 -8px;
padding: 0 8px;
top: 64px;
margin: 0 -48px;
padding: 0 48px;
background: ${s("background")};
z-index: 1;
`;
+8
View File
@@ -125,6 +125,14 @@ class User extends ParanoidModel implements Searchable {
return this.role === UserRole.Guest;
}
get isCreatedInPastDay(): boolean {
if (!this.createdAt) {
return false;
}
const oneDayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
return new Date(this.createdAt) > oneDayAgo;
}
/**
* Whether the user has been recently active. Recently is currently defined
* as within the last 5 minutes.
+24 -1
View File
@@ -47,12 +47,14 @@ function Home() {
<ResizingHeightContainer>
{!ui.languagePromptDismissed && <LanguagePrompt key="language" />}
</ResizingHeightContainer>
<Heading>{t("Home")}</Heading>
<PinnedDocuments
pins={pins}
canUpdate={can.update}
placeholderCount={count}
/>
<Heading>
<Greeting />
</Heading>
<Documents>
<Tabs>
<Tab to="/home" exact>
@@ -123,6 +125,27 @@ function Home() {
);
}
const Greeting = () => {
const { t } = useTranslation();
const user = useCurrentUser();
const hour = new Date().getHours();
if (user?.isCreatedInPastDay) {
return <>{t("Welcome")}</>;
}
let greeting;
if (hour >= 5 && hour < 12) {
greeting = t("Good morning");
} else if (hour >= 12 && hour < 17) {
greeting = t("Good afternoon");
} else {
greeting = t("Good evening");
}
return <>{greeting}</>;
};
const Documents = styled.div`
position: relative;
background: ${s("background")};
@@ -814,6 +814,10 @@
"Documents with recent activity will appear here": "Documents with recent activity will appear here",
"You haven’t created any documents yet": "You haven’t created any documents yet",
"Documents you’ve recently viewed will be here for easy access": "Documents you’ve recently viewed will be here for easy access",
"Welcome": "Welcome",
"Good morning": "Good morning",
"Good afternoon": "Good afternoon",
"Good evening": "Good evening",
"{{ count }} invites sent": "{{ count }} invites sent",
"{{ count }} invites sent_plural": "{{ count }} invites sent",
"Those email addresses are already invited": "Those email addresses are already invited",