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

Sundry fixes #500

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions app/components/Article/Contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ const insertGlossary = (pageid: string, glossary: Glossary) => {
if (!entry) return undefined
const link =
entry.pageid &&
`<a href="${questionUrl(entry)}" class="button secondary">View full definition</a>`
`<a href="${questionUrl(entry)}" target="_blank" rel="noopener noreferrer" class="button secondary">View full definition</a>`
const image = entry.image && `<img src="${entry.image}"/>`
addPopup(
e as HTMLSpanElement,
`glossary-${entry.term}`,
`<div class="glossary-popup flex-container black small">
<div class="contents col-8">
`<div class="glossary-popup flex-container black small col-${image ? 6 : 4}">
<div class="contents col-6 ${image ? '' : 'full-width'}">
<div class="small-bold">${entry.term}</div>
<div class="defintion small">${entry.contents}</div>
${link || ''}
Expand Down Expand Up @@ -161,7 +161,12 @@ const Contents = ({pageid, html, glossary}: {pageid: PageId; html: string; gloss
el.querySelectorAll('.footnote-ref > a').forEach((e) => {
const footnote = footnoteHTML(el, e as HTMLAnchorElement)
const footnoteId = (e.getAttribute('href') || '').replace('#', '')
if (footnote) addPopup(e as HTMLAnchorElement, `footnote-${footnoteId}`, footnote)
if (footnote)
addPopup(
e as HTMLAnchorElement,
`footnote-${footnoteId}`,
`<div class="footnote">${footnote}</div>`
)
})
}, [html, glossary, pageid])

Expand Down
2 changes: 1 addition & 1 deletion app/components/Article/KeepGoing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const NextArticle = ({section, next, first}: NextArticleProps) =>
</div>
<div className={`${styles.container} flex-container bordered ${styles.flex_dynamic}`}>
<div className="vertically-centered white default-bold">{next.title}</div>
<Button action={questionUrl(next)} className="primary-alt">
<Button action={questionUrl(next)} className="vertically-centered primary-alt">
{first ? 'Start' : 'Next'}
<ArrowRight />
</Button>
Expand Down
1 change: 1 addition & 0 deletions app/components/Article/KeepGoing/keepGoing.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
justify-content: space-between;
padding: var(--spacing-32);
margin-bottom: var(--spacing-56);
gap: var(--spacing-24);
}

@media (max-width: 640px) {
Expand Down
6 changes: 5 additions & 1 deletion app/components/Article/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ article .link-popup {
visibility 0s 300ms,
opacity cubic-bezier(1, 0, 1, 1) 300ms;
}
article .link-popup .footnote {
padding: var(--spacing-24) var(--spacing-24) 0 var(--spacing-24);
}

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

Expand Down
8 changes: 7 additions & 1 deletion app/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const ArticleFooter = (question: Question) => {
className="secondary"
action={question.answerEditLink || ''}
tooltip="Edit article"
props={{target: '_blank', rel: 'noopener noreferrer'}}
>
<EditIcon className="no-fill" />
</Button>
Expand Down Expand Up @@ -94,7 +95,12 @@ const ArticleActions = ({answerEditLink}: Question) => {
<Button className="secondary" action={copyLink} tooltip={tooltip}>
<CopyIcon />
</Button>
<Button className="secondary" action={answerEditLink || ''} tooltip="Edit article">
<Button
className="secondary"
action={answerEditLink || ''}
tooltip="Edit article"
props={{target: '_blank', rel: 'noopener noreferrer'}}
>
<EditIcon className="no-fill" />
</Button>
</CompositeButton>
Expand Down
8 changes: 7 additions & 1 deletion app/components/ArticlesDropdown/dropdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@
z-index: 100;
top: 80px;
position: absolute;
padding: var(--spacing-56);
justify-content: space-between;
display: flex;

transition: visibility 0.2s;
visibility: hidden;
}
.articles-dropdown-container > div {
padding: var(--spacing-56);
}

.articles-dropdown-title.top-margin-large {
margin-top: var(--spacing-56);
}
.articles-dropdown-entry {
margin: var(--spacing-12) 0;
}

.articles-dropdown-container .toc {
border-right: 1px solid var(--colors-cool-grey-200);
}
21 changes: 11 additions & 10 deletions app/components/ArticlesDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const ArticlesDropdown = ({toc, categories}: ArticlesDropdownProps) => {
className?: string
}) => (
<div className={className || ''}>
<div className="default-bold">{category}</div>
<div className="default-bold">{category} sections</div>
{toc
.filter((item) => item.category === category)
.map((item: TOCItem) => (
Expand All @@ -50,21 +50,22 @@ export const ArticlesDropdown = ({toc, categories}: ArticlesDropdownProps) => {

return shown ? null : (
<div className="articles-dropdown-container bordered col-8">
<div>
<div className="col-5 toc">
<ArticlesSection category={INTRODUCTORY} toc={toc} className="padding-bottom-32" />
<ArticlesSection category={ADVANCED} toc={toc} />
</div>

<div>
<div className="col-4">
{/*sorted right side*/}
<div className="default-bold">Browse by category</div>

{categories
?.sort(sortFuncs['by number of questions'])
.slice(0, 12)
.map((tag) => (
<Link key={tag.rowId} className="teal-500" to={tagUrl(tag)} text={tag.name} />
))}
<div className="padding-bottom-8">
{categories
?.sort(sortFuncs['by number of questions'])
.slice(0, 12)
.map((tag) => (
<Link key={tag.rowId} className="teal-500" to={tagUrl(tag)} text={tag.name} />
))}
</div>

<Button action={tagsUrl()} className="secondary">
<span onClick={hide}> Browse all categories</span>
Expand Down
12 changes: 10 additions & 2 deletions app/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ type ButtonProps = {
className?: string
tooltip?: string
disabled?: boolean
props?: {[k: string]: any}
}
const Button = ({children, action, tooltip, className, disabled = false}: ButtonProps) => {
const Button = ({children, action, tooltip, className, disabled = false, props}: ButtonProps) => {
const classes = ['button', className, tooltip && 'tooltip'].filter((i) => i).join(' ')
if (typeof action === 'string') {
return (
Expand All @@ -22,13 +23,20 @@ const Button = ({children, action, tooltip, className, disabled = false}: Button
e.preventDefault()
}
}}
{...props}
>
{children}
</Link>
)
}
return (
<button className={classes} onClick={action} data-tooltip={tooltip} disabled={disabled}>
<button
className={classes}
onClick={action}
data-tooltip={tooltip}
disabled={disabled}
{...props}
>
{children}
</button>
)
Expand Down
5 changes: 3 additions & 2 deletions app/components/ContentBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ContentBoxMain = () => (
action={questionUrl({pageid: '9OGZ'})}
actionTitle={
<>
Start reading
<span className="default-bold">Start reading</span>
<ArrowRight />
</>
}
Expand All @@ -70,6 +70,7 @@ export const ContentBoxSecond = () => {
actionTitle="Explore the arguments"
>
<ListTable
sameTab
elements={[
{title: 'What are the main sources of AI existential risk?', pageid: '8503'},
{
Expand All @@ -91,7 +92,7 @@ export const ContentBoxThird = () => {
title="Want to help with AI safety?"
action={questionUrl(article)}
actionTitle="Get involved"
classNameTable={'content-box-table main'}
classNameTable="content-box-table main"
>
<SvgGroup className="desktop-only" />
<GetInvolvedMobile className="mobile-only full-width" />
Expand Down
2 changes: 1 addition & 1 deletion app/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const FooterBar: FunctionComponent = () => {
<Link to="https://www.every.org/stampy?utm_campaign=donate-link#/donate" title="Donate" />
<Link to="https://github.com/StampyAI/stampy-ui" title="Code" />
<Link to="https://get_involved.aisafety.info/" title="Write" />
<Link to="https://discord.com/invite/Bt8PaRTDQC" title="Join us on Discord" />
<Link to="https://discord.gg/88TbjZnNyA" title="Join us on Discord" />
</div>
<div className="partners small col-4">
<p className="small-bold padding-bottom-16">Partner projects</p>
Expand Down
2 changes: 2 additions & 0 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const shouldRevalidate: ShouldRevalidateFunction = () => false

export default function App() {
const {advanced} = useToC()
console.log(advanced)
return (
<Page>
<div className="page-body">
Expand All @@ -38,6 +39,7 @@ export default function App() {
<ContentBoxSecond />
<ContentBoxThird />

<div className="desktop-only padding-bottom-56" />
<WidgetStampy />

<h3 className="grey large-bold padding-bottom-32">Advanced sections</h3>
Expand Down
3 changes: 2 additions & 1 deletion app/routes/questions.toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export const loadToC = async (request: any): Promise<LoaderResp> => {
return {
data: data
.filter(({tags}) => tags.includes(INTRODUCTORY) || tags.includes(ADVANCED))
.map(formatQuestion(1)),
.map(formatQuestion(1))
.sort((a, b) => (a.order || 0) - (b.order || 0)),
timestamp,
}
}
Expand Down
Loading