Skip to content

Commit

Permalink
Merge branch 'stampy-redesign' into stampy-redesign-591
Browse files Browse the repository at this point in the history
  • Loading branch information
buddy-web3 authored May 1, 2024
2 parents 7a92553 + eb60ebe commit 956c50b
Show file tree
Hide file tree
Showing 42 changed files with 353 additions and 248 deletions.
6 changes: 3 additions & 3 deletions app/assets/icons/book-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/components/Article/Contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ const insertGlossary = (pageid: string, glossary: Glossary) => {
addPopup(
e as HTMLSpanElement,
`glossary-${entry.term}`,
`<div class="glossary-popup flex-container black small col-${image ? 6 : 4}">
<div class="contents col-6 ${image ? '' : 'full-width'}">
`<div class="glossary-popup flex-container black small">
<div class="contents ${image ? '' : 'full-width'}">
<div class="small-bold">${entry.term}</div>
<div class="defintion small">${entry.contents}</div>
${link || ''}
Expand Down
2 changes: 1 addition & 1 deletion app/components/Article/FeedbackForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const FeedbackForm = ({

return (
<div key={pageid} className={className} onBlur={handleBlur} onFocus={onFocus}>
<div className={'col-5 feedback-container bordered'}>
<div className={'fcol-5 feedback-container bordered'}>
<span className={'black small'}>What was the problem?</span>
{hasOptions
? options.map((option, index) => (
Expand Down
2 changes: 1 addition & 1 deletion app/components/Article/KeepGoing/keepGoing.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
gap: var(--spacing-24);
}

@media (max-width: 640px) {
@media (max-width: 780px) {
.flex_dynamic {
display: flex;
flex-direction: column;
Expand Down
39 changes: 33 additions & 6 deletions app/components/Article/article.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
article {
max-width: 47.43vw;
margin: 0 auto;
flex: 100;
max-width: 800px;
min-height: 100vh;
padding-left: var(--spacing-80);
}

article.loading .contents {
overflow: hidden;
max-width: 100%;
animation: infinite-loader 3s ease-in infinite;
}
@keyframes infinite-loader {
0% {
opacity: 0;
max-width: 80px;
}
30% {
opacity: 1;
max-width: 100px;
}
100% {
opacity: 0;
}
}

article .meta {
Expand Down Expand Up @@ -58,9 +79,13 @@ article .contents p {
padding-bottom: var(--spacing-32);
}

article .contents img {
max-width: 100%;
}

article .glossary-entry {
border-bottom: 3px dotted var(--colors-cool-grey-500);
cursor: pointer;
cursor: default;
}

article .link-popup {
Expand All @@ -73,7 +98,8 @@ article .link-popup {
font-weight: 300;
line-height: 170%; /* 30.6px */
z-index: 2;
transform: translate(-20vw, var(--spacing-40));
left: calc(50% - 200px);
transform: translateY(var(--spacing-40));
transition:
visibility 0s 300ms,
opacity cubic-bezier(1, 0, 1, 1) 300ms;
Expand All @@ -83,7 +109,7 @@ article .link-popup .footnote {
}

article .glossary-popup {
max-width: 522px;
width: 522px;
height: 304px;
}

Expand Down Expand Up @@ -149,9 +175,10 @@ article a.see-more.visible:after {
content: 'See less';
}

@media only screen and (max-width: 640px) {
@media only screen and (max-width: 780px) {
article {
max-width: 100%;
padding: 0;
}
article .footer-comtainer {
flex-direction: row;
Expand Down
6 changes: 3 additions & 3 deletions app/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ArticleFooter = (question: Question) => {
<Button
className="secondary"
action={question.answerEditLink || ''}
tooltip="Edit article"
tooltip="Suggest changes in Google Docs"
props={{target: '_blank', rel: 'noopener noreferrer'}}
>
<EditIcon className="no-fill" />
Expand Down Expand Up @@ -107,7 +107,7 @@ const ArticleActions = ({answerEditLink}: Question) => {
<Button
className="secondary"
action={answerEditLink || ''}
tooltip="Edit article"
tooltip="Suggest changes in Google Docs"
props={{target: '_blank', rel: 'noopener noreferrer'}}
>
<EditIcon className="no-fill" />
Expand Down Expand Up @@ -154,7 +154,7 @@ export const Article = ({question, glossary, className}: ArticleProps) => {
const {title, text, pageid} = question

return (
<article className={className}>
<article className={`${className} ${isLoading(question) ? 'loading' : ''}`}>
<h1 className="teal-500 padding-bottom-24">{title}</h1>
<ArticleMeta question={question} className="padding-bottom-56" />

Expand Down
2 changes: 1 addition & 1 deletion app/components/ArticlesDropdown/dropdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
border-right: 1px solid var(--colors-cool-grey-200);
}

@media (max-width: 640px) {
@media (max-width: 780px) {
.articles-dropdown-container .toc {
border-right: 0;
}
Expand Down
14 changes: 7 additions & 7 deletions app/components/ArticlesDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const ArticlesDropdown = ({toc, categories}: ArticlesDropdownProps) => {
// it, so it's always shown (until the mouse is moved out, of course). To get around
// this, use this variable to simply not render the dropdown for one render, which
// will reset the CSS onHover checker.
const [shown, setShown] = useState(false)
const hide = () => setShown(true)
useEffect(() => setShown(false), [shown])
const [hidden, setHidden] = useState(false)
const hide = () => setHidden(true)
useEffect(() => setHidden(false), [hidden])
const mobile = useIsMobile()
const Link = ({
to,
Expand Down Expand Up @@ -64,9 +64,9 @@ export const ArticlesDropdown = ({toc, categories}: ArticlesDropdownProps) => {
</div>
)

return shown ? null : (
<div className="articles-dropdown-container bordered col-8">
<div className="col-5 toc">
return hidden ? null : (
<div className="articles-dropdown-container bordered fcol-8">
<div className="fcol-5 toc">
<ArticlesSection
category={INTRODUCTORY}
toc={toc}
Expand All @@ -78,7 +78,7 @@ export const ArticlesDropdown = ({toc, categories}: ArticlesDropdownProps) => {
className={mobile ? 'padding-bottom-40' : ''}
/>
</div>
<div className="col-4">
<div className="fcol-4">
{/*sorted right side*/}
<div className="default-bold">Browse by category</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Link} from '@remix-run/react'
import ChevronRight from '~/components/icons-generated/ChevronRight'
import {questionUrl} from '~/routesMapper'
import type {TOCItem} from '~/routes/questions.toc'
import './menu.css'
import './articlenav.css'

type Article = {
article: TOCItem
Expand Down Expand Up @@ -73,17 +73,24 @@ const ArticleLevel = ({article, path, current, hideChildren}: Article) => {
)
}

export const ArticlesNav = ({article, path, className}: Article) => {
export const ArticlesNav = ({
tocLoaded,
article,
path,
className,
}: {tocLoaded: boolean} & Partial<Article>) => {
const current = path ? path[path.length - 1] : ''

return (
<div className={`articles-group col-4-5 small ${className || ''}`}>
return article ? (
<div className={`articles-group small ${className || ''}`}>
<ArticleLevel article={article} path={path} current={current} hideChildren />
<hr />

{article.children?.map((item) => (
<ArticleLevel key={item.pageid} article={item} path={path} current={current} />
))}
</div>
) : (
<div className={`articles-group ${tocLoaded ? 'none' : 'loading'}`}></div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,25 @@
display: none;
}
.articles-group {
flex: none;
width: clamp(230px, 30vw, 400px);
height: fit-content;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
overflow-y: scroll;
overflow-x: hidden;
opacity: 1;
transition:
opacity 200ms,
width 200ms;
}

.articles-group.loading {
opacity: 0;
}

.articles-group.none {
width: clamp(0px, calc(100vw - 1100px), 400px);
}

.articles-title {
Expand Down Expand Up @@ -35,10 +49,10 @@
cursor: pointer;
}

/*
/*
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary#default_style
"For Webkit-based browsers, such as Safari, it is possible to control the icon display
through the non-standard CSS pseudo-element ::-webkit-details-marker.
through the non-standard CSS pseudo-element ::-webkit-details-marker.
To remove the disclosure triangle, use summary::-webkit-details-marker { display: none }."
*/
.articles-group details summary::-webkit-details-marker {
Expand All @@ -57,10 +71,10 @@
height: 8px;
position: relative;
top: 25px;
left: -5px;
left: -8px;
}

@media (max-width: 640px) {
@media (max-width: 780px) {
.articles-group {
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Link} from '@remix-run/react'
import {SearchInput} from '../SearchInput/Input'
import {Tag as TagType} from '~/server-utils/stampy'
import {tagUrl} from '~/routesMapper'
import './menu.css'
import './categoriesnav.css'
import useIsMobile from '~/hooks/isMobile'

interface CategoriesNavProps {
Expand All @@ -25,7 +25,7 @@ export const CategoriesNav = ({categories, activeCategoryId, className}: Categor
const [search, onSearch] = useState('')
const mobile = useIsMobile()
return (
<div className={['categoriesGroup bordered col-4-5', className].join(' ')}>
<div className={['categoriesGroup bordered', className].join(' ')}>
{mobile ? <h1>Categories</h1> : <p className={'small-bold'}>Categories</p>}
<div>
<SearchInput onChange={onSearch} placeholderText="Filter by keyword" />
Expand Down
4 changes: 2 additions & 2 deletions app/components/CategoriesNav/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Link} from '@remix-run/react'
import {SearchInput} from '../SearchInput/Input'
import {Tag as TagType} from '~/server-utils/stampy'
import {tagUrl} from '~/routesMapper'
import './menu.css'
import './categoriesnav.css'

interface CategoriesPageProps {
/**
Expand All @@ -15,7 +15,7 @@ interface CategoriesPageProps {
export const CategoriesPage = ({categories}: CategoriesPageProps) => {
const [search, onSearch] = useState('')
return (
<div className={'categoriesPage col-12'}>
<div className={'categoriesPage fcol-12'}>
<h1>Categories</h1>
<div>
<SearchInput onChange={onSearch} placeholderText="Filter by keyword" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.categoriesGroup {
padding: var(--spacing-12);
flex: none;
width: clamp(230px, 30vw, 400px);
}
.categoriesGroup > * {
padding: var(--spacing-16);
Expand All @@ -26,7 +28,7 @@
flex: 1;
flex-basis: 21vw;
}
@media (max-width: 640px) {
@media (max-width: 780px) {
.categoriesGroup {
width: 100%;
height: 100%;
Expand Down
13 changes: 10 additions & 3 deletions app/components/Chatbot/ChatEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Link} from '@remix-run/react'
import MarkdownIt from 'markdown-it'
import QuestionMarkIcon from '~/components/icons-generated/QuestionMark'
import BotIcon from '~/components/icons-generated/Bot'
import LinkIcon from '~/components/icons-generated/Link'
import PersonIcon from '~/components/icons-generated/Person'
import StampyIcon from '~/components/icons-generated/Stampy'
import Contents from '~/components/Article/Contents'
Expand Down Expand Up @@ -104,8 +105,9 @@ const Reference = ({id, title, authors, source, url, index}: Citation) => {
<div>
<Authors authors={authors} />
<span>{' · '}</span>
<Link className="source-link" to={url}>
{referenceSources[source as keyof typeof referenceSources] || new URL(url).host}
<Link className="source-link" to={url} target="_blank" rel="noopener noreferrer">
{referenceSources[source as keyof typeof referenceSources] || new URL(url).host}{' '}
<LinkIcon width="16" height="16" />
</Link>
</div>
</div>
Expand Down Expand Up @@ -158,7 +160,12 @@ const ChatbotReply = ({phase, content, citationsMap}: AssistantEntry) => {
}
})}
</div>
{citations?.slice(0, MAX_REFERENCES).map(Reference)}
{citations && citations.length > 0 && (
<>
<hr />
<div className="padding-top-32">{citations?.slice(0, MAX_REFERENCES).map(Reference)}</div>
</>
)}
{phase === 'followups' ? <p>Checking for followups...</p> : undefined}
</div>
)
Expand Down
12 changes: 9 additions & 3 deletions app/components/Chatbot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Link, useFetcher} from '@remix-run/react'
import StampyIcon from '~/components/icons-generated/Stampy'
import SendIcon from '~/components/icons-generated/PlaneSend'
import Button from '~/components/Button'
import {queryLLM, Entry, AssistantEntry, StampyEntry, Followup} from '~/hooks/useChat'
import {queryLLM, Entry, AssistantEntry, StampyEntry, Followup, ChatSettings} from '~/hooks/useChat'
import ChatEntry from './ChatEntry'
import './widgit.css'
import {questionUrl} from '~/routesMapper'
Expand Down Expand Up @@ -139,7 +139,12 @@ const SplashScreen = ({
</>
)

export const Chatbot = ({question, questions}: {question?: string; questions?: string[]}) => {
type ChatbotProps = {
question?: string
questions?: string[]
settings?: ChatSettings
}
export const Chatbot = ({question, questions, settings}: ChatbotProps) => {
const [followups, setFollowups] = useState<Followup[]>()

// FIXME: Generate session id
Expand Down Expand Up @@ -232,7 +237,8 @@ export const Chatbot = ({question, questions}: {question?: string; questions?: s
[...history, message],
updateReply,
sessionId,
newController
newController,
settings
)
if (!newController.signal.aborted) {
updateReply(result)
Expand Down
Loading

0 comments on commit 956c50b

Please sign in to comment.