diff --git a/.eslintrc.json b/.eslintrc.json index 860093d7a..5ff682db4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,6 +19,7 @@ }, "plugins": ["typescript-sort-keys", "unused-imports"], "rules": { + "react/prop-types": "off", "typescript-sort-keys/string-enum": [ "error", "asc", diff --git a/.prettierignore b/.prettierignore index 3e1358bbc..af1f7c669 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,4 +7,5 @@ **/.hg *.mdx *.md -*.hbs \ No newline at end of file +*.hbs +*.gif \ No newline at end of file diff --git a/package.json b/package.json index e08ba6c54..38b74be98 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,8 @@ "postcss": "^8.4.47", "prettier": "3.3.3", "tailwindcss": "^3.4.13", - "typescript": "^4.8.4" + "typescript": "^4.8.4", + "postcss-import": "^16.1.0" }, "engines": { "npm": "please-use-yarn", diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 000000000..b196fc93c --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,8 @@ +/** @type {import('postcss').PostcssConfig} */ +module.exports = { + plugins: { + 'postcss-import': {}, + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/src/components/Icons/index.tsx b/src/components/Icons/index.tsx index a41b8eb10..3730b48a2 100644 --- a/src/components/Icons/index.tsx +++ b/src/components/Icons/index.tsx @@ -170,6 +170,7 @@ export const Menu: FC<{ ) } + export const Moon: FC<{ className?: string color?: 'neutral-2' @@ -186,6 +187,167 @@ export const Moon: FC<{ ) } +export const Edit: FC<{ + className?: string + color?: 'neutral-2' +}> = ({ className, color = 'neutral-2' }) => { + return ( + + + + + + ) +} + +export const Happy: FC<{ + className?: string + color?: 'neutral-2' +}> = ({ className, color = 'neutral-2' }) => { + return ( + + + + + + + ) +} + +export const Neutral: FC<{ + className?: string + color?: 'neutral-2' +}> = ({ className, color = 'neutral-2' }) => { + return ( + + + + + + + ) +} + +export const Sad: FC<{ + className?: string + color?: 'neutral-2' +}> = ({ className, color = 'neutral-2' }) => { + return ( + + + + + + + ) +} + export type Icon = 'sun' | 'moon' export const IconMap: FC<{ diff --git a/src/components/SentimentTracking/SentimentButton.tsx b/src/components/SentimentTracking/SentimentButton.tsx new file mode 100644 index 000000000..3ddc4e3f0 --- /dev/null +++ b/src/components/SentimentTracking/SentimentButton.tsx @@ -0,0 +1,42 @@ +import React from 'react' +import { Sentiment } from '.' +import { TraceEvent } from '@uniswap/analytics' +import { BrowserEvent, DocsSentiment, DocsSentimentSection, SharedEventName } from '@uniswap/analytics-events' +import cn from 'classnames' + +interface SentimentButtonProps { + sentiment: Sentiment + icon: React.ReactNode + selected: boolean + onSelect: (sentiment: Sentiment) => void + analyticsSection: DocsSentimentSection +} + +const SentimentButton: React.FC = ({ sentiment, icon, selected, onSelect, analyticsSection }) => { + const sentimentMap: Record = { + [Sentiment.POSITIVE]: DocsSentiment.POSITIVE_SENTIMENT, + [Sentiment.NEUTRAL]: DocsSentiment.NEUTRAL_SENTIMENT, + [Sentiment.NEGATIVE]: DocsSentiment.NEGATIVE_SENTIMENT, + } + + const handleClick = () => onSelect(sentiment) + + return ( + + + + ) +} + +export default SentimentButton diff --git a/src/components/SentimentTracking/index.tsx b/src/components/SentimentTracking/index.tsx index c019226e3..675882828 100644 --- a/src/components/SentimentTracking/index.tsx +++ b/src/components/SentimentTracking/index.tsx @@ -1,9 +1,9 @@ -import { TraceEvent } from '@uniswap/analytics' -import { BrowserEvent, DocsSentiment, DocsSentimentSection, SharedEventName } from '@uniswap/analytics-events' +import { DocsSentimentSection } from '@uniswap/analytics-events' import React, { useCallback, useState } from 'react' -import { Frown, Meh, Smile } from 'react-feather' +import { Happy, Sad, Neutral } from '../Icons' +import SentimentButton from './SentimentButton' -enum Sentiment { +export enum Sentiment { NEGATIVE = 'NEGATIVE', NEUTRAL = 'NEUTRAL', POSITIVE = 'POSITIVE', @@ -18,47 +18,31 @@ export default function SentimentTracking({ analyticsSection }: { analyticsSecti ) return ( -
-
Helpful?
- - {/* +
Was this helpful?
+
+ } selected={isSentimentSelected(Sentiment.POSITIVE)} - onClick={() => { - setSelectedSentiment(Sentiment.POSITIVE) - }} - /> */} - - - {/* + } selected={isSentimentSelected(Sentiment.NEUTRAL)} - onClick={() => { - setSelectedSentiment(Sentiment.NEUTRAL) - }} - /> */} - - - {/* + } selected={isSentimentSelected(Sentiment.NEGATIVE)} - onClick={() => { - setSelectedSentiment(Sentiment.NEGATIVE) - }} - /> */} - + onSelect={setSelectedSentiment} + analyticsSection={analyticsSection} + /> +
) } diff --git a/src/css/custom.css b/src/css/custom.css index 07c844b12..6d0bd7c64 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -22,3 +22,109 @@ .default-grid { @apply grid grid-cols-4 gap-gap-large sm:grid-cols-8; } + +.breadcrumbs__link { + @apply !text-light-neutral-1 dark:!text-dark-neutral-1 !bg-transparent !p-0 !body-3; +} +.breadcrumbs__item:first-child, +.breadcrumbs__item:first-child:after { + @apply !hidden; +} +.breadcrumbs__item:not(:last-child):after { + background: url('/img/chevron.svg') center !important; + @apply text-light-neutral-1 dark:text-dark-neutral-1 !h-4 !opacity-100; +} +.docMainContainer_src-theme-DocPage-Layout-Main-styles-module { + @apply !mt-nav-h; +} +.breadcrumbs__item { + @apply inline-flex flex-row items-center; +} +.Toc__title { + @apply !body-3 text-light-neutral-1 dark:text-dark-neutral-1; +} +.theme-edit-this-page { + all: initial; +} +.theme-edit-this-page { + @apply text-light-neutral-2 dark:text-dark-neutral-2 !button-label-3; +} +.theme-edit-this-page svg { + @apply !hidden; +} +.theme-doc-toc-desktop { + @apply !relative !top-auto; +} +.Toc__container { + @apply max-h-[calc(100vh-(theme(spacing.nav-h)+2rem))] overflow-y-auto sticky top-[calc(theme(spacing.nav-h)+1rem)] hidden md:block; +} +.theme-doc-toc-mobile { + @apply !hidden; +} +.table-of-contents { + @apply !pl-0; +} +.table-of-contents__link { + @apply !text-light-neutral-2 dark:!text-dark-neutral-2 hover:!text-light-neutral-1 hover:dark:!text-dark-neutral-1 !body-3; +} +.table-of-contents__left-border { + @apply !border-0; +} +.table-of-contents__left-border li { + @apply !ml-0; +} +.table-of-contents__left-border ul { + @apply border-y-0 border-r-0 border-l-2 border-solid border-l-light-surface-3 dark:border-l-dark-surface-3 !pl-4; +} +.pagination-nav { + @apply !flex !flex-col md:!flex-row !w-full !h-auto !gap-y-2 md:!gap-y-0 md:!gap-x-3 !mt-8; +} +.pagination-nav__link { + @apply md:w-1/2 md:!grow-0 !flex !flex-col !space-y-1 bg-light-accent-2 dark:bg-dark-accent-2 hover:bg-light-accent-2-hovered hover:dark:bg-dark-accent-2-hovered text-light-accent-1 !rounded-lg !p-4 !border-0 !min-h-fit !h-auto; +} +.pagination-nav__sublabel { + @apply text-light-accent-1 !body-4 flex flex-row items-center w-fit; +} +.pagination-nav__label { + @apply !subheading-2 !text-light-accent-1; +} +.pagination-nav__label::before, +.pagination-nav__label::after { + @apply !content-none; +} +.pagination-nav:has(.pagination-nav__link--next):not(:has(.pagination-nav__link--prev)) { + @apply md:!flex-row-reverse; +} +.pagination-nav__link--next > .pagination-nav__sublabel::after { + @apply hidden md:inline-block w-4 h-4 bg-cover content-[""] bg-[url("/img/arrow-right.svg")] ml-2; +} +.pagination-nav__link--next > .pagination-nav__sublabel::before { + @apply md:hidden inline-block w-4 h-4 bg-cover content-[""] bg-[url("/img/arrow-right.svg")] mr-2; +} +.pagination-nav__link--prev > .pagination-nav__sublabel::before { + @apply inline-block w-4 h-4 bg-cover content-[""] bg-[url("/img/arrow-left.svg")] mr-2; +} +.pagination-nav__link--next > .pagination-nav__label { + @apply self-start md:self-end; +} +.pagination-nav__link--next > .pagination-nav__sublabel { + @apply md:self-end; +} +.pagination-nav__link--prev > .pagination-nav__sublabel { + @apply self-start; +} +.Sentiment__question { + @apply !mono-body-5 !text-light-neutral-1 dark:!text-dark-neutral-1; +} +.col.docItemCol_src-theme-DocItem-Layout-styles-module { + @apply sm:!max-w-full md:!max-w-[75%]; +} +.container { + @apply !mt-nav-h; +} +.theme-doc-footer-edit-meta-row { + @apply !hidden; +} +.navbar { + @apply !p-0; +} diff --git a/src/css/index.css b/src/css/index.css new file mode 100644 index 000000000..e69de29bb diff --git a/src/css/infima-overrides.css b/src/css/infima-overrides.css index dfaed7356..39b9fea0a 100644 --- a/src/css/infima-overrides.css +++ b/src/css/infima-overrides.css @@ -102,3 +102,7 @@ select { scroll-behavior: auto !important; } } + +.navbar { + all: initial; +} diff --git a/src/theme/DocBreadcrumbs.tsx b/src/theme/DocBreadcrumbs.tsx index b185b817c..ea2e501b0 100644 --- a/src/theme/DocBreadcrumbs.tsx +++ b/src/theme/DocBreadcrumbs.tsx @@ -1,16 +1,10 @@ import OriginalDocBreadcrumbs from '@theme-original/DocBreadcrumbs' -import { DocsSentimentSection } from '@uniswap/analytics-events' import React from 'react' -import SentimentTracking from '../components/SentimentTracking' - export default function DocBreadcrumbs(props) { return (
- -
- -
+
) } diff --git a/src/theme/DocItem/Layout/index.js b/src/theme/DocItem/Layout/index.js new file mode 100644 index 000000000..62410525b --- /dev/null +++ b/src/theme/DocItem/Layout/index.js @@ -0,0 +1,67 @@ +import React from 'react' +import clsx from 'clsx' +import { useWindowSize } from '@docusaurus/theme-common' +import { useDoc } from '@docusaurus/theme-common/internal' +import DocItemPaginator from '@theme/DocItem/Paginator' +import DocVersionBanner from '@theme/DocVersionBanner' +import DocVersionBadge from '@theme/DocVersionBadge' +import DocItemFooter from '@theme/DocItem/Footer' +import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile' +import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop' +import DocItemContent from '@theme/DocItem/Content' +import DocBreadcrumbs from '@theme/DocBreadcrumbs' +import EditThisPage from '@theme/EditThisPage' +import styles from './styles.module.css' +import { Edit } from '../../../components/Icons' +/** + * Decide if the toc should be rendered, on mobile or desktop viewports + */ +function useDocTOC() { + const { frontMatter, toc } = useDoc() + const windowSize = useWindowSize() + const hidden = frontMatter.hide_table_of_contents + const canRender = !hidden && toc.length > 0 + const mobile = canRender ? : undefined + const desktop = canRender && (windowSize === 'desktop' || windowSize === 'ssr') ? : undefined + return { + hidden, + mobile, + desktop, + } +} +export default function DocItemLayout({ children }) { + const docTOC = useDocTOC() + const { metadata } = useDoc() + const { editUrl } = metadata + return ( +
+
+ +
+
+ + + {docTOC.mobile} + {children} + +
+ +
+
+
+ {docTOC.desktop && ( +
+

On this page

+ {docTOC.desktop} +
+ )} + {editUrl && ( +
+ + +
+ )} +
+
+ ) +} diff --git a/src/theme/DocItem/Layout/styles.module.css b/src/theme/DocItem/Layout/styles.module.css new file mode 100644 index 000000000..d5aaec132 --- /dev/null +++ b/src/theme/DocItem/Layout/styles.module.css @@ -0,0 +1,10 @@ +.docItemContainer header + *, +.docItemContainer article > *:first-child { + margin-top: 0; +} + +@media (min-width: 997px) { + .docItemCol { + max-width: 75% !important; + } +} diff --git a/src/theme/Navbar.tsx b/src/theme/Navbar.tsx index 9c0ae4a89..7ce4d1e43 100644 --- a/src/theme/Navbar.tsx +++ b/src/theme/Navbar.tsx @@ -6,8 +6,8 @@ import ThemeSwitch from '../components/ThemeSwitch' const Navbar: FC = () => { return ( -