diff --git a/.browserslistrc b/.browserslistrc index 5372580b..426ba935 100644 --- a/.browserslistrc +++ b/.browserslistrc @@ -3,4 +3,3 @@ defaults not ie > 1 not ie_mob > 1 -maintained node versions diff --git a/.env.dist b/.env.dist new file mode 100644 index 00000000..32e724a2 --- /dev/null +++ b/.env.dist @@ -0,0 +1,6 @@ +# Host system port where the live documentation is to be made accessible +COMPOSE_START_PORT=8000 + +# Ownership of the files created in the container +COMPOSE_UID=1000 +COMPOSE_GID=1000 diff --git a/.eslintrc b/.eslintrc index 51c183ea..f1c81fc4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,6 +6,7 @@ "browser": true, "jest": true }, + "ignorePatterns": ["src/docs/_assets/generated"], "overrides": [ { "files": ["**/*.md", "**/*.mdx"], diff --git a/.github/workflows/release-management.yml b/.github/workflows/release-management.yml index 043fdf74..2c3763ff 100644 --- a/.github/workflows/release-management.yml +++ b/.github/workflows/release-management.yml @@ -24,7 +24,7 @@ jobs: run: npm ci - name: Build - run: npm run build + run: docker compose run --rm node_build_site && docker compose run --rm mkdocs_build_site - name: Test run: npm test @@ -45,7 +45,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: docs - path: docs + path: site update_release_draft: name: Update release draft diff --git a/.gitignore b/.gitignore index 374ad226..56070843 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -/.docz /dist -/docs /node_modules -lib-stats.development.html -lib-stats.html +/site +/src/docs/_assets/generated/* +.env +!.gitkeep diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc index de6a2ad6..230ac13f 100644 --- a/.markdownlint.jsonc +++ b/.markdownlint.jsonc @@ -2,9 +2,11 @@ { "default": true, + "MD033": false, // Allow inline JSX. + "MD024": false, // Allow duplicate headings "line-length": { "code_block_line_length": 120, - "tables": false - }, - "no-inline-html": false // Allow inline JSX. + "tables": false, + "code_blocks": false + } } diff --git a/.npmignore b/.npmignore index e1629866..8f059baa 100644 --- a/.npmignore +++ b/.npmignore @@ -1,10 +1,10 @@ -/.docz /.github /.idea -/docs +/docker /node_modules +/public +/site /src/docs/ -/src/gatsby-theme-docz/ /src/**/__tests__ /tests .browserslistrc @@ -13,13 +13,12 @@ .gitignore .markdownlint.jsonc babel.config.js -doczrc.js -gatsby-config.js +CONTRIBUTING.md +docker-compose.yml jest.config.js -lib-stats.development.html -lib-stats.html +mkdocs.yml package-lock.json postcss.config.js RELEASING.md stylelint.config.js -webpack.config.js +webpack.config.babel.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc8a5a24..23e2b144 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,24 +1,83 @@ ---- -name: General Guidelines -route: /contribute/guidelines -menu: Contribute ---- - # Contributing In the first place, thank you for your interest in contributing! π ## Development -To build the project: +Working on the site requires: + +* [Docker] +* [Docker Compose] + +This allows running the documentation site which serves as a development platform. + +### Configure Docker Compose + +Review the default env variable values in the `docker-compose.yml` file. +The defaults should work for most systems, but can be changed if needed. + +To change them: + +1. Create a `.env` file from the template: + + ```bash + cp .env.dist .env + ``` + +2. Edit the new `.env` file as needed + +### Use Docker Compose + +#### Node shell + +All npm commands such as `npm ci`, `npm test`, `npm run eslint` and others you +need to run them within the `node_shell` docker container. + +To log into the container, run: + +```bash +docker compose run --rm node_shell +``` + +#### Run the Dev Server + +1. Install dependencies (run within `node_shell`): + + ```bash + npm ci + ``` + +2. Run development server (run on host): + + ```bash + docker compose up node_dev_server mkdocs_dev_server + ``` + +#### Build the Project + +1. Make sure the dev server is not running (run on host): + + ```bash + docker compose down + ``` -1. Install local npm packages: `npm install` -2. Run the build: `npm run build` +2. Install dependencies (run within `node_shell`): -To run the dev server: + ```bash + npm ci + ``` -1. Install local npm packages: `npm install` -2. Run the dev server (usually on `http://localhost:3000`): `npm start` +3. Build JS (run on host): + + ```bash + docker compose run --rm node_build_site + ``` + +4. Build mkDocs (run on host): + + ```bash + docker compose run --rm mkdocs_build_site + ``` ## Git Workflow @@ -33,13 +92,13 @@ Actions), please follow these guidelines: 3. **Name your branches according to nature of change.** Choose one of: - - `bc/*` for breaking changes - - `feature/*` for features - - `bugfix/*` for bugfixes - - `refactoring/*` for refactoring of the library - - `docs/*` or `documentation/*` for changes in docs - - `maintenance/*` for maintenance (builds, dependencies, automation, etc.) - - `release/*` for [releases](/contribute/releasing) (administrators only) + * `bc/*` for breaking changes + * `feature/*` for features + * `bugfix/*` for bugfixes + * `refactoring/*` for refactoring of the library + * `docs/*` or `documentation/*` for changes in docs + * `maintenance/*` for maintenance (builds, dependencies, automation, etc.) + * `release/*` for releases (administrators only) 4. **Write clear, helpful and descriptive commit messages.** @@ -82,9 +141,8 @@ application with `npm link` so you can see it in action. 1. In React UI repository, run `npm link` 2. In your application, run `npm link @react-ui-org/react-ui` -To prevent -[Invalid Hook Call Warning](https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react) -when React UI is linked, add the following code to your app's Webpack config: +To prevent [Invalid Hook Call Warning][react-invalid-hook] when React UI is +linked, add the following code to your app's Webpack config: ```js const path = require('path'); @@ -108,30 +166,13 @@ To keep React UI consistent and predictable the following guidelines should be o ## Documenting -We use [Docz](https://docz.site) (powered by [Gatsby](https://www.gatsbyjs.com)) -as the documentation platform. The documentation itself is written in -[MDX](https://mdxjs.com) format β a human-readable blend of the popular Markdown -and JSX syntax. - -Run `npm start` to run the docs in development mode, and open -`http://localhost:3000` in your browser to see the docs in live-reload mode. - -A few things to note: - -- In order to get component props parsed and rendered by Docz, it's crucial to - **import the component into an MDX file right from its source file** β parsing - a re-exported component (typically via `index.js`) isn't currently supported. - -- If you don't want Gatsby to collect **anonymous statistics**, you may want to - disable [Gatsby telemetry](https://www.gatsbyjs.com/docs/telemetry/) by - running `npx gatsby telemetry --disable`. +We use combination of [Material for MkDocs][mkdocs-material] and [Docoff] as +the documentation platform. -- If you see the Not found page after having **changed the configuration of Docz - or Gatsby in the live-reload mode,** you may either restart the Docz - development server (`ctrl + c` and `npm start`), or try to edit an MDX file - which makes the Docz rebuild, too. +Do see their respective documentation for details. -- To **make your authoring experience better,** we recommend to make sure your - IDE understands the MDX syntax and is able to help you wrap lines in MD and - MDX files automatically (Jetbrains IDE's and VSCode support both features - out-of-the-box or through a plugin). +[Docker]: https://www.docker.com +[Docker Compose]: https://docs.docker.com/compose/ +[react-invalid-hook]: https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react +[mkdocs-material]: https://squidfunk.github.io/mkdocs-material/ +[Docoff]: https://github.com/react-ui-org/docoff diff --git a/README.md b/README.md index 8bfd64e2..c5b242bc 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ React UI is a themeable, performant, responsive UI library for React apps. Use it simply with no configuration or have full control over your design by tweaking some of the hundreds theming options available. -**[Explore React UI docs β](https://react-ui.io)** +**[Explore React UI docs β][rui-docs]** ## Key Concepts @@ -38,7 +38,7 @@ these requirements:
> Development of React UI is largely supported by -> [RACOM](https://www.racom.eu)βone of the leading global players in wireless +> [RACOM]βone of the leading global players in wireless > Critical Infrastructure. ## Quick Start Guide @@ -81,8 +81,7 @@ To install React UI in your app: ``` -Head to [the docs](https://react-ui.io) to see how to use, customize, and -extend React UI. +Head to [the docs][rui-docs] to see how to use, customize, and extend React UI. ### Development Mode @@ -114,6 +113,9 @@ Then run webpack with the `--mode=production` or `--mode=development` flag. We appreciate any contributions you might make. π -Please check out our -[Contributing Guide](https://react-ui.io/contribute/guidelines). It includes +Please check out our [Contributing Guide][gh-contributing]. It includes contribution guidelines and information on how to run and develop the project. + +[rui-docs]: https://react-ui.io +[RACOM]: https://www.racom.eu +[gh-contributing]: https://github.com/react-ui-org/react-ui/blob/master/CONTRIBUTING.md diff --git a/RELEASING.md b/RELEASING.md index 14bf12fd..baf2eb57 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,9 +1,3 @@ ---- -name: Releasing -route: /contribute/releasing -menu: Contribute ---- - # Releasing The release process is fully automated so you can release a new version just @@ -11,14 +5,14 @@ by bumping version number in `package.json`. However, there are several chances to adjust both version and changelog if you wish to do so for a reason. In order for the automation to work properly, contributors must follow the -[contributing guidelines](/contribute/guidelines). +[contributing guidelines][gh-contributing]. ## How It Works 1. Pull requests are automatically labelled by branch name. Labels are then used for: - 1. resolving next [semantic version number](https://semver.org) + 1. resolving next [semantic version number][semver] (BREAKING.FEATURE.PATCH), 2. grouping changes in changelog. @@ -31,11 +25,11 @@ See the source of `.github/workflows` for details. ## Release Process 1. **As you go:** make sure all contributions follow the contributing - guidelines, especially the - [Git workflow](/contribute/guidelines#git-workflow) (correct PR names and - branch names). Check out the release draft on - [GitHub releases page](https://github.com/react-ui-org/react-ui/releases) to - see what the changelog looks like and what will be the next version number. + guidelines, especially the [Git workflow][gh-contributing-git] (correct + PR names and branch names). Check out the release draft on + [GitHub releases page][gh-releases] to see what the changelog looks like and + what will be the next version number. + **Don't edit manually until you are ready to publish the release.** Release draft is automatically overwritten everytime a change is merged to `master`. @@ -68,3 +62,8 @@ See the source of `.github/workflows` for details. **Note:** prefix version number with `v` everywhere except in `package.json` and `package-lock.json`. + +[semver]: https://semver.org +[gh-contributing]: https://github.com/react-ui-org/react-ui/blob/master/CONTRIBUTING.md +[gh-contributing-git]: https://github.com/react-ui-org/react-ui/blob/master/CONTRIBUTING.md#git-workflow +[gh-releases]: https://github.com/react-ui-org/react-ui/releases diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..52b5b4b6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +services: + # Base services - do not run directly + mkdocs: + build: docker/mkdocs + user: ${COMPOSE_UID-1000}:${COMPOSE_GID-1000} + volumes: + - .:/workspace:z + node: + build: docker/node + user: ${COMPOSE_UID-1000}:${COMPOSE_GID-1000} + volumes: + - .:/workspace:z + + # Dev services + mkdocs_dev_server: + extends: mkdocs + entrypoint: mkdocs serve + ports: + - ${COMPOSE_START_PORT-8000}:8000 + node_dev_server: + extends: node + entrypoint: npm start + node_shell: + extends: node + entrypoint: bash + + # Build services + mkdocs_build_site: + extends: mkdocs + entrypoint: mkdocs build + node_build_site: + extends: node + entrypoint: npm run build diff --git a/docker/mkdocs/Dockerfile b/docker/mkdocs/Dockerfile new file mode 100644 index 00000000..36e67184 --- /dev/null +++ b/docker/mkdocs/Dockerfile @@ -0,0 +1,8 @@ +FROM node:16 + +RUN apt-get update && apt-get install -y python3-pip +RUN pip3 install 'mkdocs-material>=9.0.0,<10.0.0' +RUN mkdir /workspace + +COPY ./init-container.sh /root/init-container.sh +WORKDIR /workspace diff --git a/docker/mkdocs/init-container.sh b/docker/mkdocs/init-container.sh new file mode 100644 index 00000000..189fe6fd --- /dev/null +++ b/docker/mkdocs/init-container.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# This script is to be executed when the docker container is started + +# Set UID of user `node` on guest to match the UID of the user on the host machine +usermod -u $(stat -c "%u" $1) node +# Set GID of group `node` on guest to match the GID of the users primary group on the host machine +groupmod -g $(stat -c "%g" $1) node + +chown -R node /workspace diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile new file mode 100644 index 00000000..a68634b2 --- /dev/null +++ b/docker/node/Dockerfile @@ -0,0 +1,3 @@ +FROM node:16 +RUN mkdir /workspace +WORKDIR /workspace diff --git a/doczrc.js b/doczrc.js deleted file mode 100644 index a5a8ddbb..00000000 --- a/doczrc.js +++ /dev/null @@ -1,264 +0,0 @@ -import vsDarkTheme from 'prism-react-renderer/themes/vsDark'; - -const codeMaxHeight = 'min(66vh, 1000px)'; -const defaultFontFamily = '"Titillium Web", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; - -export default { - dest: 'docs', - groups: { - '': [], - Basics: [ - 'Getting Started', - 'Foundation', - ], - Components: [ - 'Actions', - 'Inputs', - 'Layouts', - 'Miscellaneous', - ], - Helpers: [ - 'CSS Helpers', - 'JS Helpers', - ], - // eslint-disable-next-line sort-keys - Guides: [ - 'Customize', - 'Contribute', - ], - }, - ignore: ['LICENSE.md', 'README.md'], - lang: 'en', - menu: [ - 'Introduction', - { - menu: [ - 'Installation', - 'Usage', - 'Browsers & Devices', - ], - name: 'Getting Started', - }, - { - menu: [ - 'Design Tokens', - 'Colors', - 'Typography', - 'Spacing', - 'Borders', - 'Shadows', - 'Breakpoints', - 'Accessibility', - 'Icons', - ], - name: 'Foundation', - }, - { - menu: [], - name: 'Actions', - }, - { - menu: [], - name: 'Inputs', - }, - { - menu: [], - name: 'Layouts', - }, - { - menu: [], - name: 'Miscellaneous', - }, - { - menu: [], - name: 'CSS Helpers', - }, - { - menu: [], - name: 'JS Helpers', - }, - { - menu: [ - 'Theming Overview', // Theming submenu - 'Forms Theming', // Theming submenu - 'Global Props', - 'Translations', - ], - name: 'Customize', - }, - { - menu: [ - 'General Guidelines', - 'API Guidelines', - 'Composition', - 'CSS Guidelines', - 'Releasing', - ], - name: 'Contribute', - }, - ], - // Use short menu items while keeping page title descriptive. - menuDisplayName: { - 'Forms Theming': 'Forms', - 'Theming Overview': 'Overview', - }, - public: '/public', - themeConfig: { - colors: { - modes: { - dark: { - text: '#ced4de', - }, - }, - }, - editor: { - fontSize: 1, - }, - fonts: { - monospace: 'var(--rui-font-family-monospace)', - }, - footer: { - navigation: true, - }, - header: { - fixed: false, - icons: 'minimal', - }, - menu: { - headings: { - rightSide: true, - }, - search: false, - }, - prism: { - dark: vsDarkTheme, - light: vsDarkTheme, - }, - search: true, - showPlaygroundEditor: false, - styles: { - Container: { - '& > div > div > div > :is(ul, ol)': { - ml: 5, - }, - '& > div > div > div > h1': { - fontFamily: defaultFontFamily, - mb: 4, - }, - '& > div > div > div > h2': { - fontSize: 5, - mb: 3, - mt: 5, - }, - '& > div > div > div > h3': { - fontSize: 4, - mb: 2, - mt: 4, - }, - '& > div > div > div > h4': { - fontSize: 3, - mb: 1, - mt: 2, - }, - '& [data-testid="live-preview"]': { - fontSize: '1rem', // Set the font size in playground to override the docs theme default. - overflow: 'auto', // Make preview scrollable. - p: 3, - }, - '& [data-testid="live-preview"] * ul': { // Reset lists in components. - ml: 0, - }, - '& [data-testid="live-preview"] > *:not(.example), & [data-testid="live-preview"] .example > *': { - m: 1, - maxWidth: ['-webkit-fill-available', '-moz-available'], // Fix overflowing full-width components in some browsers. - }, - '& [data-testid="playground"]': { - my: '1.5rem !important', - }, - '& [data-testid="playground"] > div:last-child > div': { // Visually emphasize the resize bar. - '&:hover, &:active': { - borderRightColor: 'var(--rui-color-action-selected)', - }, - borderRight: '3px solid transparent', - transition: 'border-color 200ms ease-in-out', - }, - '& [data-testid="playground"] > div[class$="NormalWrapper"]': { // Make code editor scrollable. - maxHeight: codeMaxHeight, - overflow: 'auto !important', - }, - '& [data-testid="playground"] pre': { - maxHeight: 'none', - }, - '& [data-testid="prop-name"]': { - flexShrink: 0, - }, - '.prism-code': { - my: '1.5rem !important', - }, - blockquote: { - fontStyle: 'normal', - }, - code: { - bg: 'rgba(0, 0, 0, 0.05)', - }, - 'code, pre': { - fontSize: '80%', // Adjust code font size to work better with 20px body text size. - }, - 'h1 + p': { - fontSize: 4, - }, - hr: { - my: 6, - }, - maxWidth: 1150, - p: null, - pre: { - maxHeight: codeMaxHeight, - }, - px: 4, - py: 6, - table: { - fontSize: 'var(--rui-font-size-1)', - minWidth: '0 !important', - }, - 'table tbody td:first-child': { - fontWeight: 'bold', // Emphasize prop names. - }, - 'table tbody td:first-child code': { - fontWeight: 'initial', // Revert previously set emphasize for custom property names. - }, - 'table tbody td:nth-child(2) code': { - whiteSpace: 'pre-wrap', // Preserve formatting for prop types, wrap lines when necessary. - }, - 'table td p:not(:last-child)': { - mb: 3, - }, - 'table ul, table ol': { - ml: 1, - }, - }, - Header: { - 'a:hover': { - color: 'unset', - }, - }, - a: { - '&:active': { - color: 'var(--rui-color-text-link-active)', - textDecoration: 'var(--rui-text-decoration-link-active)', - }, - '&:hover': { - color: 'var(--rui-color-text-link-hover)', - textDecoration: 'var(--rui-text-decoration-link-hover)', - }, - color: 'var(--rui-color-text-link)', - textDecoration: 'var(--rui-text-decoration-link)', - }, - root: { - '--theme-ui-colors-playground-bg': 'rgba(179, 179, 179, 0.1)', // Make components with white background stand out. - fontFamily: defaultFontFamily, - }, - }, - }, - title: 'React UI', -}; diff --git a/gatsby-config.js b/gatsby-config.js deleted file mode 100644 index 8d1aff2e..00000000 --- a/gatsby-config.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - plugins: [ - { - options: { - cssLoaderOptions: { - localIdentName: '[name]__[local]__[hash:base64:8]', - }, - sassOptions: { - includePaths: ['../node_modules'], - }, - sassRuleModulesTest: /\.scss$/, - }, - resolve: 'gatsby-plugin-sass', - }, - { - options: { - files: '**/*.{md,mdx}', - title: 'React UI', - }, - resolve: 'gatsby-theme-docz', - }, - { - resolve: '@nejcm/docz-theme-extended', - }, - ], -}; diff --git a/jest.config.js b/jest.config.js index 71bba632..90b714d9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,10 +5,8 @@ module.exports = { ], moduleNameMapper: { '\\.scss$': 'identity-obj-proxy', + '\\.svg$': '