diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index b3bf851f6..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-env node */ - -const PASCAL_CASE = "*([A-Z]*([a-z0-9]))"; -const CAMEL_CASE = "+([a-z])*([a-z0-9])*([A-Z]*([a-z0-9]))"; - -module.exports = { - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "plugin:import/recommended", - "plugin:import/typescript", - "plugin:react/recommended", - "plugin:react/jsx-runtime", - "plugin:react-hooks/recommended", - "plugin:prettier/recommended", - ], - env: { - browser: true, - }, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint", "check-file", "@shopify"], - root: true, - settings: { - "import/resolver": { - typescript: true, - node: true, - }, - react: { - version: "detect", - }, - }, - ignorePatterns: ["assets/**"], - rules: { - "@typescript-eslint/consistent-type-imports": "error", - "check-file/folder-naming-convention": [ - "error", - { "src/**/": "KEBAB_CASE" }, - ], - "check-file/filename-naming-convention": [ - "error", - { - "src/**/*.{js,ts,tsx}": `@(${CAMEL_CASE}|${PASCAL_CASE})`, - }, - { - ignoreMiddleExtensions: true, - }, - ], - "@shopify/jsx-no-hardcoded-content": [ - "warn", - { - checkProps: ["title", "aria-label"], - modules: { - "@zendeskgarden/react-tooltips": { - Tooltip: { checkProps: ["content"] }, - }, - "react-i18next": { - Trans: { allowStrings: true }, - }, - }, - }, - ], - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..430e6280d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,20 @@ +{ + "parser": "@typescript-eslint/parser", + "extends": [ + "next/core-web-vitals", + "plugin:security/recommended-legacy", + "plugin:@typescript-eslint/recommended" + ], + "plugins": ["jsx-a11y", "tailwindcss"], + "rules": { + "tailwindcss/no-custom-classname": "off", + "tailwindcss/classnames-order": "off", + "@typescript-eslint/no-unused-vars": 1, + "@typescript-eslint/ban-ts-ignore": 0, + "@typescript-eslint/ban-ts-comment": 0, + "@typescript-eslint/no-explicit-any": 0, + "no-unused-vars": 0, + "security/detect-object-injection": "off", + "jsx-a11y/alt-text": "off" + } +} diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c9311d394..eb70b2820 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,18 +1,27 @@ -## Description +### Description - + -## Screenshots +### Type(s) of changes - + -## Checklist +- [ ] Bug fix +- [ ] New feature +- [ ] Update to an existing feature -- [ ] :green_book: all commit messages follow the [conventional commits](https://conventionalcommits.org/) standard -- [ ] :arrow_left: changes are compatible with RTL direction -- [ ] :wheelchair: Changes to the UI are [tested for accessibility](./../README.md#accessibility-testing) and compliant with [WCAG 2.1](https://www.w3.org/TR/WCAG21/). -- [ ] :memo: changes are tested in Chrome, Firefox, Safari and Edge -- [ ] :iphone: changes are responsive and tested in mobile -- [ ] :+1: PR is approved by @zendesk/vikings +### Motivation for PR - \ No newline at end of file + + +### How Has This Been Tested? + + + +### Applicable screenshots + + + +### Follow-up PR + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 82b693384..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release -on: - push: - branches: - - master -jobs: - release: - name: Release - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: zendesk/checkout@v3 - with: - persist-credentials: false - - name: Setup Node.js - uses: zendesk/setup-node@v3 - with: - node-version-file: '.nvmrc' - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Build - run: yarn build - - name: Release - run: yarn semantic-release - env: - GITHUB_TOKEN: ${{ secrets.release_bot_github_token}} - GIT_AUTHOR_NAME: ${{ secrets.release_bot_git_name }} - GIT_AUTHOR_EMAIL: ${{ secrets.release_bot_git_email }} - GIT_COMMITTER_NAME: ${{ secrets.release_bot_git_name }} - GIT_COMMITTER_EMAIL: ${{ secrets.release_bot_git_email }} diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100755 index c160a7712..000000000 --- a/.husky/commit-msg +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no -- commitlint --edit ${1} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..a9cb580f3 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +.vscode +.yarn +dist +templates +translations \ No newline at end of file diff --git a/manifest.json b/manifest.json index 39dab182a..12466695e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "name": "Copenhagen Test", + "name": "Copenhagen", "author": "Zendesk", "version": "4.2.2", "api_version": 4, diff --git a/package.json b/package.json index bae00a58e..1f9183813 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "copenhagen_theme", - "version": "1.22.18", "repository": "git@github.com:zendesk/copenhagen_theme.git", "scripts": { "start": "concurrently -k -r 'rollup -c -w' 'wait-on script.js style.css && zcli themes:preview'", diff --git a/src/context/uiProvider.tsx b/src/context/uiProvider.tsx index c20b8232f..a98956b6a 100644 --- a/src/context/uiProvider.tsx +++ b/src/context/uiProvider.tsx @@ -19,7 +19,7 @@ export const useUIProvider = () => { return context; }; -export const UIProvider: FC = ({ children }) => { +export const UIProvider: FC> = ({ children }) => { const [theme, setTheme] = useState('light'); useEffect(() => { diff --git a/src/lib/types.ts b/src/lib/types.ts index 3b6961e6c..c847cbcfc 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -56,3 +56,10 @@ export type GlobalSettings = { }; connectBlockNewsletterTitle: string; }; + +export interface Navigation { + article_id: number; + html_url: string; + title: string; + snippet: string; +} diff --git a/src/modules/navigation/MobileMenuModal.tsx b/src/modules/navigation/MobileMenuModal.tsx deleted file mode 100644 index a32fc192b..000000000 --- a/src/modules/navigation/MobileMenuModal.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { FC, useState, useEffect } from 'react'; -import * as Types from '../../lib/types'; - -import { useUIProvider } from '../../context/uiProvider'; - -import { Dialog, DialogPanel } from '@headlessui/react'; -import { TextButton, PrimaryButton } from '../../base/Button'; -import ThemeSwitch from './ThemeSwitch'; -import { Close } from '../../svgs/Icons'; - -import cn from 'classnames'; - -type Props = { - globalSettings?: Types.GlobalSettings; - isOpen: boolean; - close: () => void; -}; - -const MobileMenuModal: FC = ({ globalSettings, isOpen, close }) => { - const { theme } = useUIProvider(); - const [modalTransition, setModalTransition] = useState(false); - const topNavigationApp = globalSettings?.topNavigationApp; - - const handleClose = () => { - setModalTransition(false); - setTimeout(close, 100); - }; - - useEffect(() => { - if (isOpen) { - setTimeout(() => setModalTransition(true), 100); - } - }, [isOpen]); - - return ( - -
- -
- - -
-
-

- Theme -

- -
-
- {topNavigationApp?.key && topNavigationApp?.value ? ( -
- -
- ) : null} - -
-
- ); -}; - -export default MobileMenuModal; diff --git a/src/modules/navigation/Navigation.tsx b/src/modules/navigation/Navigation.tsx deleted file mode 100644 index 3ad2762ae..000000000 --- a/src/modules/navigation/Navigation.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import { FC, useState, useEffect } from 'react'; -import type { Navigation } from "./data-types"; - -import cn from 'classnames'; - -import { MiniUnicon } from '../../svgs/Logos'; -import { Menu } from '../../svgs/Icons'; -import { PrimaryButton, ButtonBase, LinkBase } from '../../base/Button'; -import ThemeSwitch from './ThemeSwitch'; -import TopicsDropdownButton from './TopicsDropdownButton'; -import MobileMenuModal from './MobileMenuModal'; - -type Props = { - globalSettings?: Types.GlobalSettings; -}; - -const Navigation: FC = ({ globalSettings }) => { - const [scrollIsOnTop, setScrollIsOnTop] = useState(false); - const [menuIsOpen, setMenuIsOpen] = useState(false); - const topNavigationApp = globalSettings?.topNavigationApp; - - useEffect(() => { - const handleScroll = () => { - const position = window.scrollY; - if (position === 0) { - setScrollIsOnTop(true); - } else { - setScrollIsOnTop(false); - } - }; - handleScroll(); - window.addEventListener('scroll', handleScroll, { passive: true }); - - return () => { - window.removeEventListener('scroll', handleScroll); - }; - }, [setScrollIsOnTop]); - - return ( - <> - -
- { - setMenuIsOpen(false); - }} - /> - - ); -}; - -export default Navigation; diff --git a/src/modules/navigation/ThemeSwitch.tsx b/src/modules/navigation/ThemeSwitch.tsx deleted file mode 100644 index 17529d345..000000000 --- a/src/modules/navigation/ThemeSwitch.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { FC } from 'react'; - -import { useUIProvider } from '../../context/uiProvider'; - -import { IconMap, Sun, Moon } from '../../svgs/Icons'; -import { Switch } from '@headlessui/react'; - -import cn from 'classnames'; - -const ThemeSwitch: FC = () => { - const { toggleTheme, theme } = useUIProvider(); - - return ( - - - - - - - - ); -}; - -export default ThemeSwitch; diff --git a/src/modules/navigation/TopicsDropdownButton.tsx b/src/modules/navigation/TopicsDropdownButton.tsx deleted file mode 100644 index e6b5448c4..000000000 --- a/src/modules/navigation/TopicsDropdownButton.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import { FC } from 'react'; -import * as Types from '../../lib/types' - -import { useUIProvider } from '../../context/uiProvider'; - -import cn from 'classnames'; - -import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react'; -import { LinkBase } from '../../base/Button'; - -const TopicsDropdownButton: FC<{ globalSettings?: Types.GlobalSettings }> = ({ - globalSettings, -}) => { - const { theme } = useUIProvider(); - - if (!globalSettings) { - return null; - } - - return ( -
- - - - Topics - - - - {globalSettings.navigationTopics && globalSettings.navigationTopics.length > 0 - ? globalSettings.navigationTopics.map((topic) => { - return ( - - {({ close }) => ( - - {topic.title} - - )} - - ); - }) - : null} - - -
- ); -}; - -export default TopicsDropdownButton; diff --git a/src/modules/navigation/data-types/Navigation.ts b/src/modules/navigation/data-types/Navigation.ts deleted file mode 100644 index 4d7a1da67..000000000 --- a/src/modules/navigation/data-types/Navigation.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Navigation { - article_id: number; - html_url: string; - title: string; - snippet: string; -} diff --git a/src/modules/navigation/data-types/index.ts b/src/modules/navigation/data-types/index.ts deleted file mode 100644 index 8953bdfab..000000000 --- a/src/modules/navigation/data-types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./Navigation"; diff --git a/src/modules/navigation/index.ts b/src/modules/navigation/index.ts deleted file mode 100644 index 3d52448b6..000000000 --- a/src/modules/navigation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./renderNavigation"; diff --git a/src/modules/navigation/renderNavigation.tsx b/src/modules/navigation/renderNavigation.tsx deleted file mode 100644 index 0d3102ad9..000000000 --- a/src/modules/navigation/renderNavigation.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { render } from "react-dom"; -import type { Settings } from "../shared"; -import { - createTheme, - ThemeProviders, - loadTranslations, - initI18next, -} from "../shared"; -import Navigation from "./Navigation"; -import type { Navigation as NavigationProps } from "./data-types"; - -export async function renderNewRequestForm( - settings: Settings, - props: NavigationProps, - container: HTMLElement -) { - render( - - - , - container - ); -}