From cdb6c4d6026f762c54bb56f07ba57e8bdbfe21a0 Mon Sep 17 00:00:00 2001 From: davidschober Date: Fri, 4 Aug 2023 15:21:48 -0500 Subject: [PATCH] Initial commit --- .env | 2 + .eslintrc.json | 28 + .github/ISSUE_TEMPLATE/bug.md | 27 + .github/ISSUE_TEMPLATE/feature-enhancement.md | 14 + .github/pull_request_template.md | 15 + .github/workflows/aggregate.yml | 17 + .github/workflows/gh-pages.deploy.yml | 36 + .gitignore | 41 + .prettierrc.json | 0 LICENSE | 21 + README.md | 110 + canopy.js | 44 + components/Card/Card.styled.ts | 57 + components/Card/Card.tsx | 64 + components/Embed/Card.tsx | 33 + components/Embed/Slider.tsx | 7 + components/Embed/Viewer.tsx | 17 + components/Facets/Activate.styled.ts | 26 + components/Facets/Activate.tsx | 31 + components/Facets/Facet.styled.ts | 55 + components/Facets/Facet.tsx | 82 + components/Facets/Facets.styled.ts | 6 + components/Facets/Facets.tsx | 55 + components/Facets/Modal.styled.ts | 143 + components/Facets/Modal.tsx | 78 + components/Facets/Option.styled.ts | 86 + components/Facets/Option.tsx | 56 + components/Figure/Figure.styled.ts | 32 + components/Figure/Figure.tsx | 53 + components/Footer/Footer.styled.ts | 32 + components/Footer/Footer.tsx | 26 + components/Footer/ThemeMode.tsx | 39 + components/Grid/Grid.styled.ts | 57 + components/Grid/Grid.tsx | 37 + components/Grid/Item.tsx | 19 + components/Header/Header.styled.tsx | 131 + components/Header/Header.tsx | 51 + components/Hero/Hero.styled.ts | 120 + components/Hero/Hero.tsx | 59 + components/Layouts/Basic.tsx | 63 + components/Map/Map.styled.tsx | 29 + components/Map/Map.tsx | 118 + components/Map/MarkerClusterGroup.tsx | 26 + components/Nav/Items.tsx | 25 + components/Nav/ItemsLink.tsx | 58 + components/Nav/Nav.styled.ts | 94 + components/Nav/Nav.tsx | 28 + components/Related/Related.styled.ts | 7 + components/Related/Related.tsx | 24 + components/SVG/IIIF.tsx | 48 + components/Search/Header.styled.ts | 61 + components/Search/Results.tsx | 50 + components/Search/Search.styled.ts | 101 + components/Search/Search.tsx | 51 + components/Shared/Button/Button.styled.ts | 78 + components/Shared/Button/Button.tsx | 24 + components/Shared/Code/Code.styled.ts | 34 + components/Shared/Code/Code.tsx | 52 + components/Shared/Code/prism-helpers.ts | 26 + components/Shared/Container.tsx | 89 + components/Shared/Content.styled.ts | 65 + components/Shared/DefinitionList.styled.ts | 19 + components/Shared/Heading/Heading.styled.ts | 58 + components/Shared/Heading/Heading.tsx | 26 + components/Shared/Locale/Locale.styled.ts | 23 + components/Shared/Locale/Locale.tsx | 38 + components/Shared/Main.tsx | 12 + components/Shared/Markdown/Blockquote.tsx | 18 + components/Viewer/Slider.styled.ts | 73 + components/Viewer/Slider.tsx | 69 + components/Viewer/Viewer.tsx | 52 + components/Work/Inner.styled.ts | 34 + components/Work/Inner.tsx | 89 + components/layout.tsx | 16 + config/.default/canopy.default.json | 32 + config/.default/navigation.default.json | 38 + config/.default/options.default.json | 80 + config/.fixtures/canopy.presentation-2.json | 18 + config/.fixtures/canopy.presentation-3.json | 16 + config/canopy.sample.json | 26 + config/locales/en.json | 12 + config/locales/nb.json | 12 + config/locales/nn.json | 12 + config/locales/no.json | 12 + config/navigation.sample.json | 38 + config/options.sample.json | 80 + context/canopy.tsx | 92 + context/facets.tsx | 55 + global.d.ts | 3 + hooks/getLabel.ts | 28 + hooks/getResourceImage.ts | 22 + hooks/getValues.ts | 21 + hooks/sortItems.ts | 45 + hooks/useElementPosition.ts | 23 + hooks/useLocale.ts | 34 + hooks/usePageResults.ts | 55 + mdx-components.tsx | 29 + next-env.d.ts | 5 + next-sitemap.config.js | 15 + next.config.js | 77 + package-lock.json | 13713 ++++++++++++++++ package.json | 69 + pages/404.mdx | 7 + pages/_app.tsx | 69 + pages/_document.tsx | 41 + pages/about/documentation.mdx | 296 + pages/about/example.mdx | 83 + pages/about/history.mdx | 47 + pages/about/index.mdx | 26 + pages/api/facet/[label]/[value].ts | 38 + pages/api/facet/[label]/index.ts | 34 + pages/api/info.ts | 37 + pages/api/search.ts | 25 + pages/index.tsx | 117 + pages/map.tsx | 26 + pages/metadata.tsx | 76 + pages/search.tsx | 93 + pages/works/[slug].tsx | 73 + pages/works/index.tsx | 8 + public/fixtures/iiif/collection/examples.json | 173 + public/images/marker-icon.png | Bin 0 -> 1466 bytes services/build/aggregate.js | 172 + services/build/chunks.js | 49 + services/build/config.js | 54 + services/build/facets.js | 167 + services/build/log.js | 10 + services/build/request.js | 16 + services/build/search.js | 17 + services/build/shape.js | 38 + services/build/slug.js | 37 + services/constants/canopy.ts | 17 + services/facet/facets.ts | 13 + services/iiif/constructors/collection.js | 51 + services/iiif/constructors/related.ts | 18 + services/iiif/context.js | 40 + services/iiif/homepage.js | 13 + services/iiif/image.js | 44 + services/iiif/label.js | 38 + services/iiif/navPlace.ts | 29 + services/option.ts | 5 + services/search/documents.ts | 17 + services/search/request.ts | 51 + services/search/response.ts | 59 + services/search/results.ts | 46 + services/seo.ts | 64 + services/utils.ts | 2 + stitches.ts | 29 + styles/global.ts | 59 + styles/helpers/goldenRatio.ts | 1 + styles/theme/colors.ts | 43 + styles/theme/containers.ts | 4 + styles/theme/fontSizes.ts | 15 + styles/theme/fonts.ts | 9 + styles/theme/index.ts | 13 + styles/theme/media.ts | 20 + styles/theme/sizes.ts | 18 + styles/theme/transitions.ts | 12 + tsconfig.json | 39 + tsconfig.tsbuildinfo | 1 + types/canopy.ts | 89 + types/context/canopy.ts | 10 + types/context/facets.ts | 3 + types/index.ts | 10 + types/navigation.ts | 4 + 164 files changed, 20862 insertions(+) create mode 100644 .env create mode 100644 .eslintrc.json create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/feature-enhancement.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/aggregate.yml create mode 100644 .github/workflows/gh-pages.deploy.yml create mode 100644 .gitignore create mode 100644 .prettierrc.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 canopy.js create mode 100644 components/Card/Card.styled.ts create mode 100644 components/Card/Card.tsx create mode 100644 components/Embed/Card.tsx create mode 100644 components/Embed/Slider.tsx create mode 100644 components/Embed/Viewer.tsx create mode 100644 components/Facets/Activate.styled.ts create mode 100644 components/Facets/Activate.tsx create mode 100644 components/Facets/Facet.styled.ts create mode 100644 components/Facets/Facet.tsx create mode 100644 components/Facets/Facets.styled.ts create mode 100644 components/Facets/Facets.tsx create mode 100644 components/Facets/Modal.styled.ts create mode 100644 components/Facets/Modal.tsx create mode 100644 components/Facets/Option.styled.ts create mode 100644 components/Facets/Option.tsx create mode 100644 components/Figure/Figure.styled.ts create mode 100644 components/Figure/Figure.tsx create mode 100644 components/Footer/Footer.styled.ts create mode 100644 components/Footer/Footer.tsx create mode 100644 components/Footer/ThemeMode.tsx create mode 100644 components/Grid/Grid.styled.ts create mode 100644 components/Grid/Grid.tsx create mode 100644 components/Grid/Item.tsx create mode 100644 components/Header/Header.styled.tsx create mode 100644 components/Header/Header.tsx create mode 100644 components/Hero/Hero.styled.ts create mode 100644 components/Hero/Hero.tsx create mode 100644 components/Layouts/Basic.tsx create mode 100644 components/Map/Map.styled.tsx create mode 100644 components/Map/Map.tsx create mode 100644 components/Map/MarkerClusterGroup.tsx create mode 100644 components/Nav/Items.tsx create mode 100644 components/Nav/ItemsLink.tsx create mode 100644 components/Nav/Nav.styled.ts create mode 100644 components/Nav/Nav.tsx create mode 100644 components/Related/Related.styled.ts create mode 100644 components/Related/Related.tsx create mode 100644 components/SVG/IIIF.tsx create mode 100644 components/Search/Header.styled.ts create mode 100644 components/Search/Results.tsx create mode 100644 components/Search/Search.styled.ts create mode 100644 components/Search/Search.tsx create mode 100644 components/Shared/Button/Button.styled.ts create mode 100644 components/Shared/Button/Button.tsx create mode 100644 components/Shared/Code/Code.styled.ts create mode 100644 components/Shared/Code/Code.tsx create mode 100644 components/Shared/Code/prism-helpers.ts create mode 100644 components/Shared/Container.tsx create mode 100644 components/Shared/Content.styled.ts create mode 100644 components/Shared/DefinitionList.styled.ts create mode 100644 components/Shared/Heading/Heading.styled.ts create mode 100644 components/Shared/Heading/Heading.tsx create mode 100644 components/Shared/Locale/Locale.styled.ts create mode 100644 components/Shared/Locale/Locale.tsx create mode 100644 components/Shared/Main.tsx create mode 100644 components/Shared/Markdown/Blockquote.tsx create mode 100644 components/Viewer/Slider.styled.ts create mode 100644 components/Viewer/Slider.tsx create mode 100644 components/Viewer/Viewer.tsx create mode 100644 components/Work/Inner.styled.ts create mode 100644 components/Work/Inner.tsx create mode 100644 components/layout.tsx create mode 100644 config/.default/canopy.default.json create mode 100644 config/.default/navigation.default.json create mode 100644 config/.default/options.default.json create mode 100644 config/.fixtures/canopy.presentation-2.json create mode 100644 config/.fixtures/canopy.presentation-3.json create mode 100644 config/canopy.sample.json create mode 100644 config/locales/en.json create mode 100644 config/locales/nb.json create mode 100644 config/locales/nn.json create mode 100644 config/locales/no.json create mode 100644 config/navigation.sample.json create mode 100644 config/options.sample.json create mode 100644 context/canopy.tsx create mode 100644 context/facets.tsx create mode 100644 global.d.ts create mode 100644 hooks/getLabel.ts create mode 100644 hooks/getResourceImage.ts create mode 100644 hooks/getValues.ts create mode 100644 hooks/sortItems.ts create mode 100644 hooks/useElementPosition.ts create mode 100644 hooks/useLocale.ts create mode 100644 hooks/usePageResults.ts create mode 100644 mdx-components.tsx create mode 100644 next-env.d.ts create mode 100644 next-sitemap.config.js create mode 100644 next.config.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 pages/404.mdx create mode 100644 pages/_app.tsx create mode 100644 pages/_document.tsx create mode 100644 pages/about/documentation.mdx create mode 100644 pages/about/example.mdx create mode 100644 pages/about/history.mdx create mode 100644 pages/about/index.mdx create mode 100644 pages/api/facet/[label]/[value].ts create mode 100644 pages/api/facet/[label]/index.ts create mode 100644 pages/api/info.ts create mode 100644 pages/api/search.ts create mode 100644 pages/index.tsx create mode 100644 pages/map.tsx create mode 100644 pages/metadata.tsx create mode 100644 pages/search.tsx create mode 100644 pages/works/[slug].tsx create mode 100644 pages/works/index.tsx create mode 100644 public/fixtures/iiif/collection/examples.json create mode 100644 public/images/marker-icon.png create mode 100644 services/build/aggregate.js create mode 100644 services/build/chunks.js create mode 100644 services/build/config.js create mode 100644 services/build/facets.js create mode 100644 services/build/log.js create mode 100644 services/build/request.js create mode 100644 services/build/search.js create mode 100644 services/build/shape.js create mode 100644 services/build/slug.js create mode 100644 services/constants/canopy.ts create mode 100644 services/facet/facets.ts create mode 100644 services/iiif/constructors/collection.js create mode 100644 services/iiif/constructors/related.ts create mode 100644 services/iiif/context.js create mode 100644 services/iiif/homepage.js create mode 100644 services/iiif/image.js create mode 100644 services/iiif/label.js create mode 100644 services/iiif/navPlace.ts create mode 100644 services/option.ts create mode 100644 services/search/documents.ts create mode 100644 services/search/request.ts create mode 100644 services/search/response.ts create mode 100644 services/search/results.ts create mode 100644 services/seo.ts create mode 100644 services/utils.ts create mode 100644 stitches.ts create mode 100644 styles/global.ts create mode 100644 styles/helpers/goldenRatio.ts create mode 100644 styles/theme/colors.ts create mode 100644 styles/theme/containers.ts create mode 100644 styles/theme/fontSizes.ts create mode 100644 styles/theme/fonts.ts create mode 100644 styles/theme/index.ts create mode 100644 styles/theme/media.ts create mode 100644 styles/theme/sizes.ts create mode 100644 styles/theme/transitions.ts create mode 100644 tsconfig.json create mode 100644 tsconfig.tsbuildinfo create mode 100644 types/canopy.ts create mode 100644 types/context/canopy.ts create mode 100644 types/context/facets.ts create mode 100644 types/index.ts create mode 100644 types/navigation.ts diff --git a/.env b/.env new file mode 100644 index 0000000..1a71bfc --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +NEXT_PUBLIC_URL = "https://canopy-iiif.vercel.app" +NEXT_PUBLIC_BASE_PATH = "" \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..04e763f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "plugins": ["@typescript-eslint", "testing-library"], + "extends": [ + "plugin:@typescript-eslint/recommended", + "next", + "next/core-web-vitals", + "prettier" + ], + "overrides": [ + // Only uses Testing Library lint rules in test files + { + "files": [ + "**/__tests__/**/*.[jt]s?(x)", + "**/?(*.)+(spec|test).[jt]s?(x)" + ], + "extends": ["plugin:testing-library/react"] + } + ], + "rules": { + // "sort-keys": "error", + // "sort-imports": "error", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/sort-type-union-intersection-members": "error", + "@typescript-eslint/ban-ts-comment": "off" + } +} diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..4ac104c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,27 @@ +--- +name: Bug +about: Report an issue +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature-enhancement.md b/.github/ISSUE_TEMPLATE/feature-enhancement.md new file mode 100644 index 0000000..c57d228 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-enhancement.md @@ -0,0 +1,14 @@ +--- +name: Feature/Enhancement +about: New feature or enhancement +title: '' +labels: enhancement +assignees: '' + +--- + +## Description + +## Done Looks Like +- [ ] to do 1 +- [ ] to do 2 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..90442f6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +# What does this do? + +_Please include a summary of the changes and the related issue. Please also include relevant motivation and context._ + +## What type of change is this? + +- [ ] ๐Ÿ› **Bug fix** (non-breaking change addressing an issue) +- [ ] โœจ **New feature or enhancement** (non-breaking change which adds functionality) +- [ ] ๐Ÿงจ **Breaking change** (fix or feature that would cause existing functionality to not work as expected) +- [ ] ๐Ÿšง **Maintenance or refinement of codebase structur**e (ex: dependency updates) +- [ ] ๐Ÿ“˜ **Documentation update** + +## Additional Notes + +_Please include any extra notes here._ diff --git a/.github/workflows/aggregate.yml b/.github/workflows/aggregate.yml new file mode 100644 index 0000000..9eaaf5b --- /dev/null +++ b/.github/workflows/aggregate.yml @@ -0,0 +1,17 @@ +name: Test IIIF Collection Aggregation/Build +on: push +jobs: + aggregate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: npm install + - name: IIIF Presentation API 2.x Collection (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-2.json + - name: IIIF Presentation API 2.x Collection (Build) + run: npm run test-build + - name: IIIF Presentation API 3.0 Collection (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-3.json + - name: IIIF Presentation API 3.0 Collection (Build) + run: npm run test-build diff --git a/.github/workflows/gh-pages.deploy.yml b/.github/workflows/gh-pages.deploy.yml new file mode 100644 index 0000000..cbb009b --- /dev/null +++ b/.github/workflows/gh-pages.deploy.yml @@ -0,0 +1,36 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + env: + NEXT_PUBLIC_URL: https://canopy-iiif.github.io + NEXT_PUBLIC_BASE_PATH: /canopy-iiif + + strategy: + matrix: + node-version: [14.x] + + steps: + - name: Get files + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Install packages + run: npm ci + - name: Export static files + run: npm run build:static + - name: Add .nojekyll file + run: touch ./out/.nojekyll + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: out diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7205ab1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +.canopy +.vscode + +public/api +public/robots.txt +public/sitemap* \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..e69de29 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aaeadbc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Mat Jordan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f139436 --- /dev/null +++ b/README.md @@ -0,0 +1,110 @@ +# Canopy IIIF + +A purely IIIF sourced static site generator using Next.js. Canopy is an application that will build a browseable and searchable digital collections style static site entirely from a IIIF Collection and the items it contains. + +- [Demo (Vercel)](https://canopy-iiif.vercel.app/) +- [Demo (Static)](https://canopy-iiif.github.io/canopy-iiif/) +- [Documentation](https://canopy-iiif.vercel.app/about) + +> **Warning** +> Canopy is a work in progress and being built in public. + +## Examples + +### [Nez Perce](https://canopy-iiif-git-nez-perce-iiif.vercel.app/) + +- IIIF Presentation API 3.0 +- 119 items +- Provided by Northwestern University Libraries + +### [William Cox Cochran Photographic Collection](https://canopy-iiif.vercel.app/) + +- IIIF Presentation API 3.0 +- 90 items +- Provided by University of Tennessee Libraries +- `navPlace` + Map + +### [The Botanical photography of Alan S. Heilman](https://canopy-iiif-git-heilman-mathewjordan.vercel.app/) + +- IIIF Presentation API 3.0 +- 1120 items +- Provided by University of Tennessee Libraries + +### [The Chimney Tops 2 Wildfires In Memory And Art](https://canopy-iiif-git-rfta-artists-mathewjordan.vercel.app/) + +- IIIF Presentation API 3.0 w/ Video Canvases +- 43 items +- Provided by University of Tennessee Libraries + +### [Canonici](https://canopy-iiif-git-canonici-mathewjordan.vercel.app/) + +- IIIF Presentation API 2.0 +- 529 items +- Provided by Bodleian Libraries, University of Oxford + +## Roadmap + +### Content + +- [x] Manifest as a `/work/` page +- [ ] Collection as a `/collection/` page +- [ ] Documentation for best-practice incorporating non-IIIF front matter +- [x] Homepage metadata sliders + +### Data Aggregration + +- [x] Collection of Manifests (i.e. `depth === 1`) +- [ ] Collection of Collections (i.e. `depth > 1`) +- [x] Harvesting of curated metadata labels +- [ ] Leveraging BCP 47 and internationalization + +### Search + +- [x] Basic search on label(s) +- [ ] No results language +- [x] Search on summary and metadata entries +- [x] Search page facets on curated metadata +- [x] `next/link` routing from Work metadata to search page facets + +### User Interface & Experience + +- [x] Fully Responsive +- [x] Continuous scroll & lazy load of search results +- [ ] Custom theme support + +### Configuration + +- [x] Localization preferences +- [x] Site title label override +- [ ] Slug pattern options + +## Setup + +### Install Dependencies + +```shell +# installation +npm i +``` + +### Running in Development + +```shell +# development +npm run dev +``` + +### Building in Production + +```shell +# build +npm run build +``` + +## Configuration + +Canopy IIIF uses a default configuration `config/.default/canopy.default.json` for demonstration purposes if a custom one is not set. The build process will read from a custom configuration file at `config/canopy.json` if it exists. Please review [configuration documentation](https://canopy-iiif.vercel.app/about) for customization of Canopy IIIF. + +## License + +This project is [licensed](https://github.com/canopy-iiif/canopy-iiif/blob/main/LICENSE) under the MIT License. diff --git a/canopy.js b/canopy.js new file mode 100644 index 0000000..80860f7 --- /dev/null +++ b/canopy.js @@ -0,0 +1,44 @@ +require("dotenv").config(); +const aggregate = require("./services/build/aggregate"); +const { + getConfig, + getOptions, + getNavigation, +} = require("./services/build/config"); +const args = process.argv; + +(() => { + const path = args + .find((value) => value.includes("--path=")) + ?.split("=") + ?.pop(); + + const config = getConfig(path); + const options = getOptions(); + const navigation = getNavigation(); + const { prod, dev } = config; + + config.environment = args.includes("dev") ? dev : prod; + config.options = options; + + const url = args.includes("dev") + ? `http://localhost:5001` + : process.env.NEXT_PUBLIC_URL; + const basePath = process.env.NEXT_PUBLIC_BASE_PATH; + const baseUrl = basePath ? `${url}${basePath}` : url; + + const env = { + CANOPY_CONFIG: { + ...config.environment, + navigation: navigation, + ...config.options, + url, + basePath, + baseUrl, + }, + }; + + aggregate.build(env.CANOPY_CONFIG); +})(); + +module.exports = { getConfig }; diff --git a/components/Card/Card.styled.ts b/components/Card/Card.styled.ts new file mode 100644 index 0000000..7d40390 --- /dev/null +++ b/components/Card/Card.styled.ts @@ -0,0 +1,57 @@ +import { styled } from "@/stitches"; + +const Content = styled("div", { + padding: "$gr3 0 0", + + h4: { + margin: "0", + fontWeight: "400", + fontSize: "$gr4", + fontFamily: "$bookTight", + textDecoration: "none !important", + }, + + span: { + display: "block", + margin: "0.25rem 0 0", + fontWeight: "300", + fontSize: "0.8333rem", + color: "$slate10", + }, +}); + +const Placeholder = styled("div", { + backgroundColor: "$slate6", + width: "100%", + height: "100%", + overflowY: "hidden", + borderRadius: "3px", + transition: "$canopyAll", +}); + +const Wrapper = styled("div", { + display: "flex", + width: "100%", + maxWidth: "240px", + position: "relative", + + a: { + display: "flex", + flexDirection: "column", + width: "100%", + color: "$slate12", + textDecoration: "none !important", + transition: "$canopyAll", + + [`&:hover, &:focus`]: { + color: "$indigo10", + + [`${Placeholder}`]: { + transform: "scale3d(1.02, 1.02, 1.02)", + boxShadow: "3px 3px 8px #0002", + }, + }, + }, +}); + +export { Content, Placeholder, Wrapper }; diff --git a/components/Card/Card.tsx b/components/Card/Card.tsx new file mode 100644 index 0000000..1123a91 --- /dev/null +++ b/components/Card/Card.tsx @@ -0,0 +1,64 @@ +import { Content, Placeholder, Wrapper } from "@/components/Card/Card.styled"; +import Link from "next/link"; +import Figure from "@/components/Figure/Figure"; +import * as AspectRatio from "@radix-ui/react-aspect-ratio"; +import { getJsonByURI } from "@/services/utils"; +import { getPresentation3 } from "@/services/iiif/context"; +import { useInView } from "react-intersection-observer"; +import { m, LazyMotion, domAnimation, MotionConfig } from "framer-motion"; +import { useEffect, useState } from "react"; +import { Label } from "@samvera/nectar-iiif"; + +interface CardProps { + resource: any; +} + +const Card: React.FC = ({ resource }) => { + const [aspectRatio, setAspectRatio] = useState(); + const { label, homepage, thumbnail } = resource; + + useEffect(() => { + /** + * temporary aspect ratio calculation for demo collection + */ + getJsonByURI(resource.id).then((json) => { + const manifest = getPresentation3(json); + const { width, height } = manifest.items + ? manifest.items[0].items[0].items[0].body + : undefined; + setAspectRatio(width / height); + }); + + // if (Array.isArray(thumbnail) && thumbnail[0]) + // setAspectRatio(thumbnail[0].width / thumbnail[0].height); + }, [thumbnail]); + + const { ref, inView } = useInView(); + + if (!aspectRatio) return <>; + + return ( + + + + + + {inView && resource && ( + + +
+ + + )} + + + + + + + + ); +}; + +export default Card; diff --git a/components/Embed/Card.tsx b/components/Embed/Card.tsx new file mode 100644 index 0000000..8488b4a --- /dev/null +++ b/components/Embed/Card.tsx @@ -0,0 +1,33 @@ +import { useEffect, useState } from "react"; +import Card from "@/components/Card/Card"; +import { canopyManifests } from "@/services/constants/canopy"; + +const EmbedCard = ({ id }: { id: string }) => { + const [resource, setResource] = useState(); + const manifests = canopyManifests(); + + useEffect(() => { + const item = manifests.find((manifest) => manifest.id === id); + + if (item) + setResource({ + id: id, + type: "Manifest", + label: item.label, + thumbnail: item.thumbnail, + homepage: [ + { + id: `/works/${item.slug}`, + label: item.label, + type: "Text", + }, + ], + }); + }, [id]); + + if (!resource) return null; + + return ; +}; + +export default EmbedCard; diff --git a/components/Embed/Slider.tsx b/components/Embed/Slider.tsx new file mode 100644 index 0000000..44b3e7f --- /dev/null +++ b/components/Embed/Slider.tsx @@ -0,0 +1,7 @@ +import Slider from "@/components/Viewer/Slider"; + +const EmbedSlider = ({ id }: { id: string }) => { + return ; +}; + +export default EmbedSlider; diff --git a/components/Embed/Viewer.tsx b/components/Embed/Viewer.tsx new file mode 100644 index 0000000..1f4f9a3 --- /dev/null +++ b/components/Embed/Viewer.tsx @@ -0,0 +1,17 @@ +import Viewer from "@/components/Viewer/Viewer"; + +const EmbedViewer = ({ id }: { id: string }) => { + return ( + + ); +}; + +export default EmbedViewer; diff --git a/components/Facets/Activate.styled.ts b/components/Facets/Activate.styled.ts new file mode 100644 index 0000000..eaa3484 --- /dev/null +++ b/components/Facets/Activate.styled.ts @@ -0,0 +1,26 @@ +import { styled } from "@/stitches"; +import * as Dialog from "@radix-ui/react-dialog"; + +const FacetsActivateIndicator = styled("span", { + position: "absolute", + display: "flex", + justifyContent: "center", + alignItems: "center", + top: "-$gr1", + right: "$gr2", + width: "$gr3", + height: "$gr3", + fontSize: "$gr1", + color: "$indigo1", + backgroundColor: "$indigo12", + borderRadius: "50%", +}); + +const FacetsActivateStyled = styled(Dialog.Trigger, { + position: "relative", + right: "0", + transition: "$canopySlideIn", + boxShadow: "none", +}); + +export { FacetsActivateIndicator, FacetsActivateStyled }; diff --git a/components/Facets/Activate.tsx b/components/Facets/Activate.tsx new file mode 100644 index 0000000..98c5c67 --- /dev/null +++ b/components/Facets/Activate.tsx @@ -0,0 +1,31 @@ +import { useFacetsState } from "@/context/facets"; +import { MixerHorizontalIcon } from "@radix-ui/react-icons"; +import React from "react"; +import { ButtonStyled } from "../Shared/Button/Button.styled"; +import { + FacetsActivateIndicator, + FacetsActivateStyled, +} from "./Activate.styled"; +import { LocaleString } from "@/hooks/useLocale"; + +const FacetsActivate: React.FC = () => { + const { facetsState } = useFacetsState(); + const { facetsActive } = facetsState; + + const { length } = Array.from(facetsActive.keys()).filter( + (key) => key !== "q" + ); + + return ( + + + {LocaleString("searchFilter")} + {length > 0 && ( + {length} + )} + + + ); +}; + +export default FacetsActivate; diff --git a/components/Facets/Facet.styled.ts b/components/Facets/Facet.styled.ts new file mode 100644 index 0000000..9c1e140 --- /dev/null +++ b/components/Facets/Facet.styled.ts @@ -0,0 +1,55 @@ +import { styled } from "@/stitches"; +import * as Accordion from "@radix-ui/react-accordion"; + +const FacetsFacetActivate = styled(Accordion.Trigger, { + display: "flex", + justifyContent: "space-between", + width: "100%", + padding: "$gr2 0", + backgroundColor: "transparent", + border: "none", + fontFamily: "$bookTight", + fontSize: "$gr4", + cursor: "pointer", + borderTop: "1px solid $slate4", + + "&:hover, &:focus": { + color: "$indigo11", + }, + svg: { + transition: "$canopyAll", + transform: "rotate(-90deg)", + color: "$slate10", + }, + + "&[aria-expanded='true']": { + color: "$slate12 !important", + fontWeight: "800", + + svg: { + color: "$slate12 !important", + transform: "rotate(0deg)", + }, + }, +}); + +const FacetsFacetContent = styled(Accordion.Content, { + padding: "$gr1 0 $gr4", +}); + +const FacetsFacetHeader = styled(Accordion.Header, {}); + +const FacetsFacetStyled = styled(Accordion.Item, { + "&:first-child": { + [`${FacetsFacetActivate}`]: { + border: "none", + }, + }, +}); + +export { + FacetsFacetActivate, + FacetsFacetContent, + FacetsFacetHeader, + FacetsFacetStyled, +}; diff --git a/components/Facets/Facet.tsx b/components/Facets/Facet.tsx new file mode 100644 index 0000000..c0fe8cf --- /dev/null +++ b/components/Facets/Facet.tsx @@ -0,0 +1,82 @@ +import { useFacetsState } from "@/context/facets"; +import { ChevronDownIcon } from "@radix-ui/react-icons"; +import React, { useEffect, useState } from "react"; +import { + FacetsFacetActivate, + FacetsFacetContent, + FacetsFacetHeader, + FacetsFacetStyled, +} from "./Facet.styled"; +import FacetsOption from "./Option"; +import { LocaleString } from "@/hooks/useLocale"; + +interface FacetsFacetProps { + label: string; + slug: string; + values: any; +} + +export const FacetsFacet: React.FC = ({ + label, + slug, + values, +}) => { + const { facetsState } = useFacetsState(); + const { facetsActive } = facetsState; + + /** + * + */ + const params = facetsActive?.toString(); + const defaultValue = { + slug: "", + value: LocaleString("searchFilterAny"), + }; + + const [active, setActive] = useState({ + slug: "", + value: LocaleString("searchFilterAny"), + }); + + useEffect(() => { + const activeSlug = facetsActive?.get(slug); + setActive( + activeSlug + ? { + slug: activeSlug, + value: values.find((entry: any) => entry.slug === activeSlug) + ?.value, + } + : defaultValue + ); + }, [facetsActive, params, slug, values]); + + return ( + + + + + {label} + + {active.value} + + + + {values.map((option: any, index: number) => { + const identifier = `${slug}-${option.slug}-${index}`; + return ( + + ); + })} + + + ); +}; + +export default FacetsFacet; diff --git a/components/Facets/Facets.styled.ts b/components/Facets/Facets.styled.ts new file mode 100644 index 0000000..3813968 --- /dev/null +++ b/components/Facets/Facets.styled.ts @@ -0,0 +1,6 @@ +import { styled } from "@/stitches"; +import * as Dialog from "@radix-ui/react-dialog"; + +const FacetsStyled = styled(Dialog.Root, {}); + +export { FacetsStyled }; diff --git a/components/Facets/Facets.tsx b/components/Facets/Facets.tsx new file mode 100644 index 0000000..e4b93d9 --- /dev/null +++ b/components/Facets/Facets.tsx @@ -0,0 +1,55 @@ +import { FacetsStyled } from "./Facets.styled"; +import React, { useEffect, useState } from "react"; +import FacetsModal from "./Modal"; +import FacetsActivate from "./Activate"; +import { FacetsProvider, useFacetsState } from "@/context/facets"; +import { useCanopyState } from "@/context/canopy"; +import { useRouter } from "next/router"; + +const Facets = () => { + const { asPath } = useRouter(); + const [isModalOpen, setIsModalOpen] = useState(false); + const { facetsDispatch } = useFacetsState(); + const { canopyDispatch, canopyState } = useCanopyState(); + const { headerVisible, searchParams } = canopyState; + + useEffect(() => { + facetsDispatch({ + type: "updateFacetsActive", + facetsActive: searchParams, + }); + }, [searchParams, facetsDispatch]); + + const handleDialogChange = () => { + setIsModalOpen(!isModalOpen); + canopyDispatch({ + type: "updateHeaderVisible", + headerVisible: !headerVisible, + }); + }; + + useEffect(() => { + setIsModalOpen(false); + canopyDispatch({ + type: "updateHeaderVisible", + headerVisible: true, + }); + }, [asPath, canopyDispatch]); + + return ( + + + + + ); +}; + +const FacetsWrapper = () => { + return ( + + + + ); +}; + +export default FacetsWrapper; diff --git a/components/Facets/Modal.styled.ts b/components/Facets/Modal.styled.ts new file mode 100644 index 0000000..cdeafb8 --- /dev/null +++ b/components/Facets/Modal.styled.ts @@ -0,0 +1,143 @@ +import { styled } from "@/stitches"; +import * as Dialog from "@radix-ui/react-dialog"; +import { slateA } from "@radix-ui/colors"; +import { maxWidths } from "@/styles/theme/containers"; + +const FacetsModalContent = styled(Dialog.Content, { + width: `calc(100% - $gr5 * 2)`, + maxWidth: maxWidths.default, + maxHeight: `calc(100% - $gr5 * 2)`, + background: "$slate2", + position: "fixed", + top: `$gr5`, + left: `50%`, + overflowY: "auto", + zIndex: "10", + borderRadius: "3px", + boxShadow: `5px 5px 13px ${slateA.slateA7}`, + borderTop: "1px solid $slateA1", + borderBottom: "1px solid $slateA4", + transform: "translateX(-50%)", + overflow: "clip", + display: "flex", + + "@lg": { + width: `calc(100% - $gr4 * 2)`, + maxHeight: `calc(100% - $gr4 * 2)`, + top: `$gr4`, + }, + + "@sm": { + width: `calc(100% - $gr3 * 2)`, + maxHeight: `calc(100% - $gr3 * 2)`, + top: `$gr3`, + }, +}); + +const FacetsModalContentInner = styled("div", { + display: "flex", + flexDirection: "column", + flexWrap: "nowrap", + width: "100%", + overflow: "scroll", +}); + +const FacetsModalContentHeader = styled("header", { + display: "flex", + flexGrow: "0", + justifyContent: "space-between", + padding: "$gr3 $gr4", + color: "$slate9", + fontSize: "$gr3", + fontFamily: "$bookTight", + fontWeight: "300", + alignItems: "center", + + "@sm": { + padding: "$gr2 $gr3", + }, +}); + +const FacetsModalContentFooter = styled("footer", { + display: "flex", + flexGrow: "0", + justifyContent: "space-between", + padding: "$gr3 $gr4", + + "@sm": { + padding: "$gr2 $gr3", + }, +}); + +const FacetsModalContentBody = styled("div", { + display: "flex", + flexDirection: "column", + flexGrow: "1", + borderTop: "1px solid $slate4", + borderBottom: "1px solid $slate4", + overflowY: "scroll !important", + padding: "$gr3 $gr4", + + "@sm": { + padding: "$gr2 $gr3", + }, +}); + +const FacetsModalTitle = styled(Dialog.Title, {}); + +const FacetsModalClose = styled(Dialog.Close, { + display: "flex", + justifyContent: "center", + alignItems: "center", + border: "none", + borderRadius: "50%", + color: "$slate10", + background: "transparent", + cursor: "pointer", + width: "$gr4", + height: "$gr4", + transition: "$canopyAll", +}); + +const FacetsModalOverlay = styled(Dialog.Overlay, { + backgroundColor: "$slateA8", + position: "fixed", + top: 0, + left: 0, + right: 0, + bottom: 0, + display: "grid", + placeItems: "center", + overflowY: "auto", + zIndex: "10", + transition: "$canopyAll", + + "&:hover": { + backgroundColor: "$slateA9", + }, + + "&::after": { + position: "fixed", + zIndex: "11", + background: "linear-gradient(180deg, $slate2, #0000)", + width: "100%", + height: "$gr9", + left: "0", + top: "0", + content: "", + }, +}); + +const FacetsModalPortal = styled(Dialog.Portal, {}); + +export { + FacetsModalClose, + FacetsModalContent, + FacetsModalContentFooter, + FacetsModalContentInner, + FacetsModalContentHeader, + FacetsModalContentBody, + FacetsModalOverlay, + FacetsModalPortal, + FacetsModalTitle, +}; diff --git a/components/Facets/Modal.tsx b/components/Facets/Modal.tsx new file mode 100644 index 0000000..818f23e --- /dev/null +++ b/components/Facets/Modal.tsx @@ -0,0 +1,78 @@ +import * as Accordion from "@radix-ui/react-accordion"; +import { + FacetsModalClose as ContentClose, + FacetsModalContent as Content, + FacetsModalContentBody as ContentBody, + FacetsModalContentFooter as ContentFooter, + FacetsModalContentHeader as ContentHeader, + FacetsModalContentInner as ContentInner, + FacetsModalOverlay as Overlay, + FacetsModalPortal as Portal, + FacetsModalTitle as ContentTitle, +} from "./Modal.styled"; +import Facet from "./Facet"; +import FACETS from "@/.canopy/facets"; +import React from "react"; +import { Cross2Icon } from "@radix-ui/react-icons"; +import { ButtonStyled } from "../Shared/Button/Button.styled"; +import { useFacetsState } from "@/context/facets"; +import { useRouter } from "next/router"; +import { LocaleString } from "@/hooks/useLocale"; + +interface FacetsModalProps { + handleSubmit: () => void; +} + +const FacetsModal: React.FC = ({ handleSubmit }) => { + const { facetsState, facetsDispatch } = useFacetsState(); + const { facetsActive } = facetsState; + const router = useRouter(); + + const handleClearAll = () => { + FACETS.forEach((facet: any) => facetsActive.delete(facet.slug)); + facetsDispatch({ + type: "updateFacetsActive", + facetsActive: facetsActive, + }); + }; + + const handleViewResults = () => { + router.push({ pathname: "/search", query: facetsActive.toString() }); + handleSubmit(); + }; + + return ( + + + + + + + {LocaleString("searchFilter")} + + + + + + + + {FACETS.map((facet: any) => ( + + ))} + + + + + {LocaleString("searchFilterClear")} + + + {LocaleString("searchFilterSubmit")} + + + + + + ); +}; + +export default FacetsModal; diff --git a/components/Facets/Option.styled.ts b/components/Facets/Option.styled.ts new file mode 100644 index 0000000..33b2f7c --- /dev/null +++ b/components/Facets/Option.styled.ts @@ -0,0 +1,86 @@ +import { styled } from "@/stitches"; +import { indigoA } from "@radix-ui/colors"; +import * as Checkbox from "@radix-ui/react-checkbox"; + +const OptionLabel = styled("label", { + transition: "$canopyAll", + cursor: "pointer", + fontWeight: "500", + + variants: { + isChecked: { + true: { + color: "$slate12 !important", + fontWeight: "800", + }, + }, + }, + + "&:hover, &:focus": { + color: "$indigo11", + }, + + span: { + color: "$slate11 !important", + fontSize: "$gr2", + }, +}); + +const OptionCheckbox = styled(Checkbox.Root, { + position: "relative", + zIndex: "0", + display: "flex", + flexDirection: "column", + justifyContent: "center", + alignItems: "center", + width: "$gr3", + height: "$gr3", + margin: "0 $gr1 0 0", + background: "$slate4", + boxShadow: "inset 1px 1px 2px #0002", + border: "none", + borderRadius: "50%", // 3px for checkbox + cursor: "pointer", + transition: "$canopyAll", + flexShrink: "0", + + "&::before": { + position: "absolute", + width: "100%", + height: "100%", + content: "", + background: "linear-gradient(-45deg, $indigo11, $indigo8)", + opacity: "0", + borderRadius: "50%", // 3px for checkbox + transition: "$canopyAll", + zIndex: "0", + }, + + "&[aria-checked='true']": { + boxShadow: "1px 1px 2px ${indigoA.indigoA4}", + + "&::before": { + opacity: "1", + }, + }, +}); + +const OptionCheckboxIndicator = styled(Checkbox.Indicator, { + position: "absolute", + zIndex: "1", + color: "$indigo1", + textShadow: `1px 1px 2px ${indigoA.indigoA12}`, +}); + +const OptionStyled = styled("span", { + display: "flex", + margin: "0 0 $gr1", + fontSize: "$gr3", + color: "$slate11", + + "&:last-child": { + margin: "0", + }, +}); + +export { OptionCheckbox, OptionCheckboxIndicator, OptionLabel, OptionStyled }; diff --git a/components/Facets/Option.tsx b/components/Facets/Option.tsx new file mode 100644 index 0000000..7a98ecf --- /dev/null +++ b/components/Facets/Option.tsx @@ -0,0 +1,56 @@ +import { + OptionCheckbox, + OptionCheckboxIndicator, + OptionLabel, + OptionStyled, +} from "./Option.styled"; +import { CheckIcon } from "@radix-ui/react-icons"; +import React from "react"; +import { useFacetsState } from "@/context/facets"; + +interface FacetsOptionProps { + active: boolean; + facet: string; + identifier: string; + option: any; +} + +export const FacetsOption: React.FC = ({ + active, + facet, + identifier, + option, +}) => { + const { facetsDispatch, facetsState } = useFacetsState(); + const { facetsActive } = facetsState; + + const handleCheckedChange = (checked: boolean) => { + facetsActive.delete(facet); + checked && facetsActive.append(facet, option.slug); + + facetsDispatch({ + type: "updateFacetsActive", + facetsActive: facetsActive, + }); + }; + + return ( + + + + + + + + {option.value} ({option.doc_count}) + + + ); +}; + +export default FacetsOption; diff --git a/components/Figure/Figure.styled.ts b/components/Figure/Figure.styled.ts new file mode 100644 index 0000000..33c5317 --- /dev/null +++ b/components/Figure/Figure.styled.ts @@ -0,0 +1,32 @@ +import { styled } from "@/stitches"; + +const Image = styled("img", { + position: "relative", + zIndex: "1", + width: "100%", + height: "100%", + objectFit: "contain", + transition: "$canopyAll", + opacity: 0, + + [`&.loaded`]: { + opacity: 1, + }, +}); + +const Wrapper = styled("figure", { + backgroundColor: "$slate6", + display: "flex", + width: "100%", + height: "100%", + padding: "0", + margin: "0", + position: "relative", + overflow: "hidden", + zIndex: "0", + borderRadius: "3px", + boxShadow: "2px 2px 5px #0001", + transition: "$canopyAll", +}); + +export { Image, Wrapper }; diff --git a/components/Figure/Figure.tsx b/components/Figure/Figure.tsx new file mode 100644 index 0000000..3a6e2fa --- /dev/null +++ b/components/Figure/Figure.tsx @@ -0,0 +1,53 @@ +import React, { useState, useEffect, useRef } from "react"; +import { Image, Wrapper } from "@/components/Figure/Figure.styled"; +import clsx from "clsx"; +import { getResourceImage } from "@/hooks/getResourceImage"; + +interface FigureProps { + resource: any; + region?: string; + size?: string; + isCover?: boolean; +} + +const Figure: React.FC = ({ + resource, + region = "full", + size = "400,", + isCover = false, +}) => { + const [image, setImage] = useState(); + const [loaded, setLoaded] = useState(false); + const imgRef = useRef(null); + + useEffect(() => { + setImage(getResourceImage(resource, size, region)); + + // @ts-ignore + if (imgRef?.current && imgRef?.current?.complete) setLoaded(true); + }, []); + + return ( + + setLoaded(true)} + className={clsx("source", loaded && "loaded")} + /> + + ); +}; + +export default Figure; diff --git a/components/Footer/Footer.styled.ts b/components/Footer/Footer.styled.ts new file mode 100644 index 0000000..3437048 --- /dev/null +++ b/components/Footer/Footer.styled.ts @@ -0,0 +1,32 @@ +import { styled } from "@/stitches"; +import { slateA } from "@radix-ui/colors"; + +const FooterContent = styled("div", { + display: "flex", + justifyContent: "space-between", + fontSize: "$gr3", + fontWeight: "500", +}); + +const FooterStyled = styled("footer", { + boxShadow: `inset 1px 2px 2px ${slateA.slateA3}`, + padding: "$gr3 0", + marginTop: "$gr6", +}); + +const CollectionLink = styled("a", { + color: "$indigo11", + fill: "$indigo11", + display: "flex", + alignItems: "center", + textDecoration: "none", + + svg: { + marginRight: "$gr2", + height: "$gr3", + color: "inherit", + fill: "inherit", + }, +}); + +export { FooterContent, FooterStyled, CollectionLink }; diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx new file mode 100644 index 0000000..2119af0 --- /dev/null +++ b/components/Footer/Footer.tsx @@ -0,0 +1,26 @@ +import React from "react"; +import IIIF from "@/components/SVG/IIIF"; +import ThemeMode from "./ThemeMode"; +import { CollectionLink, FooterContent, FooterStyled } from "./Footer.styled"; +import Container from "../Shared/Container"; +import { LocaleString } from "@/hooks/useLocale"; + +const { collection } = process.env.CANOPY_CONFIG as any; + +const Footer = () => { + return ( + + + + + + {LocaleString("footerSourceCollection")} + + + + + + ); +}; + +export default Footer; diff --git a/components/Footer/ThemeMode.tsx b/components/Footer/ThemeMode.tsx new file mode 100644 index 0000000..2392cf6 --- /dev/null +++ b/components/Footer/ThemeMode.tsx @@ -0,0 +1,39 @@ +import React from "react"; +import { useTheme } from "next-themes"; +import { useEffect, useState } from "react"; +import { ButtonStyled } from "../Shared/Button/Button.styled"; +import { LocaleString } from "@/hooks/useLocale"; + +const ThemeMode = () => { + const [mounted, setMounted] = useState(false); + const { theme, setTheme } = useTheme(); + + const toggleTheme = LocaleString("footerToggleTheme"); + + useEffect(() => setMounted(true), []); + + const handleTheme = (currentTheme: string) => { + switch (currentTheme) { + case "light": + setTheme("dark"); + break; + case "dark": + setTheme("light"); + break; + } + }; + + if (!mounted) return <>; + + return ( + handleTheme(theme as string)} + buttonSize="small" + > + {toggleTheme} + + ); +}; + +export default ThemeMode; diff --git a/components/Grid/Grid.styled.ts b/components/Grid/Grid.styled.ts new file mode 100644 index 0000000..becca79 --- /dev/null +++ b/components/Grid/Grid.styled.ts @@ -0,0 +1,57 @@ +import { styled } from "@/stitches"; +import Masonry from "react-masonry-css"; + +const GridItem = styled("div", { + paddingBottom: "$gr5", + zIndex: "1", + + "@xxs": { + paddingBottom: "$gr3", + }, + + "@xs": { + paddingBottom: "$gr3", + }, + + "@sm": { + paddingBottom: "$gr4", + }, + + "@md": { + paddingBottom: "$gr4", + }, +}); + +const GridStyled = styled(Masonry, { + display: "flex", + width: "auto", + position: "relative", + padding: "$gr2 0", + zIndex: "1", + + ".canopy-grid-column": { + marginLeft: "$gr5", + + "@xxs": { + marginLeft: "$gr3", + }, + + "@xs": { + marginLeft: "$gr3", + }, + + "@sm": { + marginLeft: "$gr4", + }, + + "@md": { + marginLeft: "$gr4", + }, + + "&:first-child": { + marginLeft: "0", + }, + }, +}); + +export { GridItem, GridStyled }; diff --git a/components/Grid/Grid.tsx b/components/Grid/Grid.tsx new file mode 100644 index 0000000..72bd1d1 --- /dev/null +++ b/components/Grid/Grid.tsx @@ -0,0 +1,37 @@ +import React, { ReactNode } from "react"; +import GridItem, { GridItemProps } from "@/components/Grid/Item"; +import { GridStyled } from "@/components/Grid/Grid.styled"; +import { width } from "@/styles/theme/media"; + +interface GridProps { + children: ReactNode | ReactNode[]; +} + +interface GridComposition { + Item: React.FC; +} + +const Grid: GridComposition & React.FC = ({ children }) => { + const columns = { + default: 6, + [width.xl]: 5, + [width.lg]: 4, + [width.md]: 4, + [width.sm]: 3, + [width.xs]: 2, + }; + + return ( + + {children} + + ); +}; + +Grid.Item = GridItem; + +export default Grid; diff --git a/components/Grid/Item.tsx b/components/Grid/Item.tsx new file mode 100644 index 0000000..525ae4b --- /dev/null +++ b/components/Grid/Item.tsx @@ -0,0 +1,19 @@ +import React from "react"; +import Card from "@/components/Card/Card"; +import { GridItem as ItemStyled } from "@/components/Grid/Grid.styled"; + +export interface GridItemProps { + item: any; +} + +const GridItem: React.FC = ({ item }) => { + if (!item) return <>; + + return ( + + + + ); +}; + +export default GridItem; diff --git a/components/Header/Header.styled.tsx b/components/Header/Header.styled.tsx new file mode 100644 index 0000000..3cb206c --- /dev/null +++ b/components/Header/Header.styled.tsx @@ -0,0 +1,131 @@ +import { styled } from "@/stitches"; +import { slateA } from "@radix-ui/colors"; + +const Title = styled("span", { + display: "flex", + marginRight: "$gr2", + fontFamily: "$bookTight", + fontSize: "$gr4", + fontWeight: "800", + + "@sm": { + marginRight: "0", + }, +}); + +const ResponsiveActions = styled("div", { + flexGrow: "1", + display: "none", + justifyContent: "flex-end", + + button: { + display: "flex", + flexDirection: "column", + justifyContent: "center", + background: "transparent", + border: "none", + fontSize: "$gr3", + height: "calc(($gr1 * 2) + $gr4 + 1px)", + cursor: "pointer", + }, + + "@sm": { + display: "flex", + }, +}); + +const Actions = styled("div", { + flexGrow: "1", + display: "flex", + justifyContent: "flex-end", + + "@sm": { + flexDirection: "column-reverse", + backgroundColor: "$slate1", + position: "absolute", + width: "100%", + padding: "$gr1 0 $gr3", + overflow: "hidden", + left: "0", + top: "-10000px", + boxShadow: `1px 2px 2px ${slateA.slateA4}`, + }, + + variants: { + showNav: { + true: { + top: "calc($gr4 + ($gr2 * 2))", + }, + }, + }, +}); + +const Content = styled("div", { + width: "100%", + padding: "$gr1 $gr5", + backgroundColor: "$slate1", + display: "flex", + flexDirection: "row", + justifyContent: "space-between", + color: "$slate1", + fontSize: "1rem", + lineHeight: "1.5rem", + alignItems: "center", + zIndex: "1", + boxShadow: `1px 1px 3px ${slateA.slateA6}`, + boxSizing: "border-box", + + "@xl": { + padding: "$gr1 $gr4", + }, + + "@lg": { + padding: "$gr1 $gr4", + }, + + "@md": { + padding: "$gr1 $gr4", + }, + + "@sm": { + padding: "$gr1 $gr4", + }, + + "@xs": { + padding: "$gr1 $gr3", + }, + + "@xxs": { + padding: "$gr1 $gr3", + }, + + [`& ${Title} a`]: { + textDecoration: "none", + color: "$slate12", + + "&:hover, &:focus": { + color: "$indigo10", + }, + }, +}); + +const Wrapper = styled("header", { + position: "fixed", + width: "100%", + zIndex: "10", + top: "0", + display: "flex", + flexDirection: "column", + transition: "$canopyOpacity", + opacity: "1", + + variants: { + isVisible: { + false: { + opacity: "0", + }, + }, + }, +}); + +export { Actions, Content, ResponsiveActions, Title, Wrapper }; diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx new file mode 100644 index 0000000..f98e228 --- /dev/null +++ b/components/Header/Header.tsx @@ -0,0 +1,51 @@ +import React, { useEffect, useState } from "react"; +import Link from "next/link"; +import Locale from "@/components/Shared/Locale/Locale"; +import Nav from "@/components/Nav/Nav"; +import Search from "@/components/Search/Search"; +import { Content, Title, Wrapper } from "@/components/Header/Header.styled"; +import collections from "@/.canopy/collections.json"; +import { Label } from "@samvera/nectar-iiif"; +import { Actions, ResponsiveActions } from "./Header.styled"; +import { HamburgerMenuIcon } from "@radix-ui/react-icons"; +import { useRouter } from "next/router"; +import { useCanopyState } from "@/context/canopy"; + +// @ts-ignore +const navItems = process.env.CANOPY_CONFIG.navigation.primary; + +const Header = () => { + const [showNav, setShowNav] = useState(false); + const router = useRouter(); + const { pathname, query } = router; + const { canopyState } = useCanopyState(); + const { headerVisible } = canopyState; + + useEffect(() => setShowNav(false), [pathname, query]); + + const handleShowNav = () => setShowNav(!showNav); + + return ( + + + + <Link href="/"> + <Label label={collections[0].label} as="span" /> + </Link> + + + + + + +