diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..e4dfd9d3 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,20 @@ +module.exports = { + root: true, + env: { + browser: true, + es2024: true, + }, + extends: ["eslint:recommended", "plugin:prettier/recommended"], + parserOptions: { + ecmaVersion: 2024, + sourceType: "module", + }, + rules: { + // disabled rules that enforce comment/empty-line requirements per request + 'padding-line-between-statements': 'off', + 'no-multiple-empty-lines': 'off', + 'lines-between-class-members': 'off', + 'line-comment-position': 'off', + 'no-inline-comments': 'off' + }, +}; diff --git a/.github/actions/node_env_setup/action.yml b/.github/actions/node_env_setup/action.yml new file mode 100644 index 00000000..a489827e --- /dev/null +++ b/.github/actions/node_env_setup/action.yml @@ -0,0 +1,44 @@ +name: Set up Node.js environment +description: Install pnpm, configure Node from .nvmrc, enable cache and install dependencies. + +inputs: + node-version-file: + description: Path to .nvmrc-like file + required: false + default: .nvmrc + pnpm-version: + description: pnpm version to use + required: false + default: "10" + install-dependencies: + description: Whether to run pnpm install --frozen-lockfile + required: false + default: "true" + +runs: + using: composite + steps: + - name: Setup pnpm (via Corepack) + shell: bash + run: | + corepack enable + if [ -n "${{ inputs.pnpm-version }}" ]; then + corepack prepare pnpm@${{ inputs.pnpm-version }} --activate || corepack prepare pnpm@latest --activate + else + corepack prepare pnpm@latest --activate + fi + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ${{ inputs.node-version-file }} + cache: pnpm + + - name: Enable corepack + shell: bash + run: corepack enable + + - name: Install dependencies + if: ${{ inputs.install-dependencies == 'true' }} + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..f5428eba --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,43 @@ +name: Lint + +on: + pull_request: + +permissions: + contents: read + +concurrency: + group: lint-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Enable Corepack and prepare pnpm + run: corepack enable && corepack prepare pnpm@10 --activate + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Format check + run: pnpm run format:check + + - name: Lint HTML + run: pnpm run lint:html + + - name: Lint JS + run: pnpm run lint:js + + - name: Lint CSS + run: pnpm run lint:css diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..e2cd58ea --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,56 @@ +name: Deploy to GitHub Pages + +on: + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Enable Corepack and prepare pnpm + run: corepack enable && corepack prepare pnpm@10 --activate + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: dist + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 00000000..e2676107 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,115 @@ +name: Preview + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +permissions: + contents: write + pull-requests: write + +concurrency: + group: preview-${{ github.ref }} + cancel-in-progress: true + +jobs: + # ── Deploy preview on open / push ───────────────────────────────────────── + deploy: + if: github.event.action != 'closed' + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Enable Corepack and prepare pnpm + run: corepack enable && corepack prepare pnpm@10 --activate + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + + - name: Publish preview to gh-pages + env: + BRANCH: ${{ github.head_ref }} + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + + # stash the build output outside the working tree + DIST=$(mktemp -d) + cp -r dist/. "$DIST/" + + # switch to gh-pages (create orphan if it doesn't exist yet) + git fetch origin gh-pages 2>/dev/null && git checkout gh-pages || \ + git checkout --orphan gh-pages && git rm -rf . --quiet + + # sync the preview subfolder + rm -rf "previews/${BRANCH}" + mkdir -p "previews/${BRANCH}" + cp -r "$DIST/." "previews/${BRANCH}/" + + # ensure GitHub Pages doesn't skip underscore/dot folders + touch .nojekyll + + git add .nojekyll "previews/${BRANCH}" + git diff --cached --quiet || \ + git commit -m "ci(preview): update ${BRANCH}" + git push origin gh-pages + + - name: Comment preview URL on PR + uses: actions/github-script@v7 + with: + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const branch = '${{ github.head_ref }}'; + const url = `https://${owner}.github.io/${repo}/previews/${branch}/`; + const marker = ''; + const body = `${marker}\n🔍 **Preview:** [${url}](${url})`; + + const comments = await github.rest.issues.listComments({ + owner, repo, issue_number: context.issue.number, + }); + const existing = comments.data.find(c => c.body.includes(marker)); + + if (existing) { + await github.rest.issues.updateComment({ + owner, repo, comment_id: existing.id, body, + }); + } else { + await github.rest.issues.createComment({ + owner, repo, issue_number: context.issue.number, body, + }); + } + + # ── Cleanup preview when PR is closed / merged ──────────────────────────── + cleanup: + if: github.event.action == 'closed' + runs-on: ubuntu-latest + + steps: + - name: Checkout gh-pages branch + uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Remove preview folder + run: | + if [ -d "previews/${{ github.head_ref }}" ]; then + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + git rm -rf "previews/${{ github.head_ref }}" + git commit -m "ci(preview): remove ${{ github.head_ref }}" + git push + else + echo "No preview to remove for ${{ github.head_ref }}" + fi diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index ae51eecc..00000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Generate new release -on: - push: - tags: - - 'v2*' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - ref: main - - name: Use Node.js 14.x 🪢 - uses: actions/setup-node@v1 - with: - node-version: 14.x - - name: git config - run: | - git config user.name "${GITHUB_ACTOR}" - git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" - - run: sudo apt-get update && sudo apt-get install -y zip - - run: npm ci - - run: npm run build - - run: npm i extract-changelog-release - - name: Generate Release Body - run: npx extract-changelog-release > RELEASE_BODY.md - - run: sh ./scripts/create-release-attachment.sh - - uses: ncipollo/release-action@v1 - with: - artifacts: './dist/zip/*.zip' - bodyFile: 'RELEASE_BODY.md' - token: ${{ secrets.GITHUB_TOKEN }} - - name: Publish on gh-pages - run: | - git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - npm run documentation-deploy-to-gh-pages - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update_docs.yml b/.github/workflows/update_docs.yml index 49b4a3c2..f9651c47 100644 --- a/.github/workflows/update_docs.yml +++ b/.github/workflows/update_docs.yml @@ -1,27 +1,41 @@ name: Update documentation + on: workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: update-docs + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 ref: main - - name: Use Node.js 14.x 🪢 - uses: actions/setup-node@v1 + + - name: Set up Node.js environment + uses: ./.github/actions/node_env_setup with: - node-version: 14.x + node-version-file: .nvmrc + pnpm-version: "10" + install-dependencies: "true" + - name: git config run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + - run: sudo apt-get update && sudo apt-get install -y zip - - run: npm ci + - name: Publish on gh-pages run: | git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - npm run documentation-deploy-to-gh-pages + pnpm run documentation-deploy-to-gh-pages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 9c17bd92..3bdd52eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ +node_modules/ +dist/ .DS_Store -node_modules -src/index.html -dist \ No newline at end of file diff --git a/.htmlvalidate.json b/.htmlvalidate.json new file mode 100644 index 00000000..83ad2b66 --- /dev/null +++ b/.htmlvalidate.json @@ -0,0 +1,6 @@ +{ + "extends": ["html-validate:recommended"], + "rules": { + "void-style": ["error", { "style": "selfclosing" }] + } +} diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..8bad5f5c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,9 @@ +#!/usr/bin/env sh +. "$(dirname "$0")/_/husky.sh" +# +#!/usr/bin/env sh +. "$(dirname "$0")/_/husky.sh" + +# Use pnpm to run lint-staged without attempting a global exec install +# `pnpm -s lint-staged` runs the script silently and works across pnpm versions +pnpm -s lint-staged diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 00000000..0ac0dabc --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,5 @@ +{ + "pages/**/*.html": ["prettier --write", "pnpm run lint:html"], + "js/**/*.js": ["prettier --write", "pnpm run lint:js:fix"], + "styles/**/*.css": ["prettier --write", "pnpm run lint:css:fix"] +} diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..a45fd52c --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..2312d389 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +node_modules/ +dist/ +.DS_Store + +# optional: ignore build helpers +scripts/*.cjs + + + +# ignore package files and lockfiles +package.json +package-lock.json +pnpm-lock.yaml +yarn.lock + diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..cb182b78 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "printWidth": 100, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": true, + "trailingComma": "es5", + "endOfLine": "lf" +} diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 00000000..15ce9219 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,20 @@ +{ + "extends": ["stylelint-config-idiomatic-order"], + "plugins": ["stylelint-prettier"], + "rules": { + "prettier/prettier": true, + "no-descending-specificity": null, + "scss/no-global-function-names": null, + "scss/comment-no-empty": null, + "scss/at-if-no-null": null, + "scss/at-extend-no-missing-placeholder": null, + "no-invalid-position-at-import-rule": null, + "rule-empty-line-before": [ + "always-multi-line", + { + "except": ["first-nested"], + "ignore": ["after-comment"] + } + ] + } +} diff --git a/CHANGELOG.md b/CHANGELOG.md index a7309ba7..af72c666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,131 +1,96 @@ ## [2.4.3](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.4.2...v2.4.3) (2024-09-25) - ### Bug Fixes -* aligned home for school theme -* close mobile menu pressing esc button - - +- aligned home for school theme +- close mobile menu pressing esc button ## [2.4.2](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.4.1...v2.4.2) (2024-07-31) - ### Bug Fixes -* remove uppercase and several bugs ([9e7ea9c](https://github.com/italia/design-scuole-pagine-statiche/commit/9e7ea9c28073f30c86cd26000022c51400feb4d2)) - - +- remove uppercase and several bugs ([9e7ea9c](https://github.com/italia/design-scuole-pagine-statiche/commit/9e7ea9c28073f30c86cd26000022c51400feb4d2)) ## [2.4.1](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.4.0...v2.4.1) (2024-01-08) - ### Bug Fixes -* changed `.container` padding ([bcf66b5](https://github.com/italia/design-scuole-pagine-statiche/commit/bcf66b556202b92597a4bf442c0e7e58941552ba)) -* changed cols size ([a9fc3bf](https://github.com/italia/design-scuole-pagine-statiche/commit/a9fc3bff98175d6e967df9c0d4d976fc4680aabe)) - +- changed `.container` padding ([bcf66b5](https://github.com/italia/design-scuole-pagine-statiche/commit/bcf66b556202b92597a4bf442c0e7e58941552ba)) +- changed cols size ([a9fc3bf](https://github.com/italia/design-scuole-pagine-statiche/commit/a9fc3bff98175d6e967df9c0d4d976fc4680aabe)) ### Features -* changed 'didattica' sections colors ([#70](https://github.com/italia/design-scuole-pagine-statiche/issues/70)) ([2d474c7](https://github.com/italia/design-scuole-pagine-statiche/commit/2d474c751463ef458ea1129b68560a70bfeeee20)) - - +- changed 'didattica' sections colors ([#70](https://github.com/italia/design-scuole-pagine-statiche/issues/70)) ([2d474c7](https://github.com/italia/design-scuole-pagine-statiche/commit/2d474c751463ef458ea1129b68560a70bfeeee20)) # [2.4.0](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.3.0...v2.4.0) (2023-12-22) - ### Bug Fixes -* **a11y:** focus on element using keyboard ([534a188](https://github.com/italia/design-scuole-pagine-statiche/commit/534a1882b3e74e9c06fb200ad39c9eb807b25c0f)) -* missing classes ([7f4aed2](https://github.com/italia/design-scuole-pagine-statiche/commit/7f4aed2b2933d62200629f8bc4b62bfddfadd4d0)) -* removed ie9 classes and minor improvements to css - +- **a11y:** focus on element using keyboard ([534a188](https://github.com/italia/design-scuole-pagine-statiche/commit/534a1882b3e74e9c06fb200ad39c9eb807b25c0f)) +- missing classes ([7f4aed2](https://github.com/italia/design-scuole-pagine-statiche/commit/7f4aed2b2933d62200629f8bc4b62bfddfadd4d0)) +- removed ie9 classes and minor improvements to css ### Features -* pagina argomenti ([#63](https://github.com/italia/design-scuole-pagine-statiche/issues/63)) ([57178c9](https://github.com/italia/design-scuole-pagine-statiche/commit/57178c9ffdc4605b59c9eba0efd3cf757ec81d82)) - - +- pagina argomenti ([#63](https://github.com/italia/design-scuole-pagine-statiche/issues/63)) ([57178c9](https://github.com/italia/design-scuole-pagine-statiche/commit/57178c9ffdc4605b59c9eba0efd3cf757ec81d82)) # [2.3.0](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.2.0...v2.3.0) (2023-07-04) - ### Bug Fixes -* breadcrumbx titles ([#51](https://github.com/italia/design-scuole-pagine-statiche/issues/51)) ([4780d54](https://github.com/italia/design-scuole-pagine-statiche/commit/4780d5425e3eaed3c169a96f428304105388959b)) -* content and design ([ade2b79](https://github.com/italia/design-scuole-pagine-statiche/commit/ade2b79dc236caad2384d46e4ac274cceee7669a)) -* document page index ([1e1dc6f](https://github.com/italia/design-scuole-pagine-statiche/commit/1e1dc6ff490d4384427678c99b8abf5c0725e88c)) -* elementi luogo ([1bb5b47](https://github.com/italia/design-scuole-pagine-statiche/commit/1bb5b47ef38a67c9cedaa59e52bc6cc8c451d92e)) -* office name ([6d95dfa](https://github.com/italia/design-scuole-pagine-statiche/commit/6d95dfa877e8c4c144b71bb7c849e2f3b0b20598)) -* removed media slider ([6464dae](https://github.com/italia/design-scuole-pagine-statiche/commit/6464daeb84648af763785c9d78590380b75fee35)) -* removed secondary nav item ([#45](https://github.com/italia/design-scuole-pagine-statiche/issues/45)) ([c277039](https://github.com/italia/design-scuole-pagine-statiche/commit/c2770392c6c17bf35ccbd8615c00df22467b6699)) -* scrolling mobile page places with map ([432b451](https://github.com/italia/design-scuole-pagine-statiche/commit/432b451b892a662ecf2e2c1d9143fb3274fdd7a2)) -* update service data element ([#37](https://github.com/italia/design-scuole-pagine-statiche/issues/37)) ([b6a346a](https://github.com/italia/design-scuole-pagine-statiche/commit/b6a346a517f81810ed767917fb4f600e63c20b17)) -* wrong data-element ([ffb9c8e](https://github.com/italia/design-scuole-pagine-statiche/commit/ffb9c8e420224a7ea17a46f236fb6878c0f9cdc2)) - +- breadcrumbx titles ([#51](https://github.com/italia/design-scuole-pagine-statiche/issues/51)) ([4780d54](https://github.com/italia/design-scuole-pagine-statiche/commit/4780d5425e3eaed3c169a96f428304105388959b)) +- content and design ([ade2b79](https://github.com/italia/design-scuole-pagine-statiche/commit/ade2b79dc236caad2384d46e4ac274cceee7669a)) +- document page index ([1e1dc6f](https://github.com/italia/design-scuole-pagine-statiche/commit/1e1dc6ff490d4384427678c99b8abf5c0725e88c)) +- elementi luogo ([1bb5b47](https://github.com/italia/design-scuole-pagine-statiche/commit/1bb5b47ef38a67c9cedaa59e52bc6cc8c451d92e)) +- office name ([6d95dfa](https://github.com/italia/design-scuole-pagine-statiche/commit/6d95dfa877e8c4c144b71bb7c849e2f3b0b20598)) +- removed media slider ([6464dae](https://github.com/italia/design-scuole-pagine-statiche/commit/6464daeb84648af763785c9d78590380b75fee35)) +- removed secondary nav item ([#45](https://github.com/italia/design-scuole-pagine-statiche/issues/45)) ([c277039](https://github.com/italia/design-scuole-pagine-statiche/commit/c2770392c6c17bf35ccbd8615c00df22467b6699)) +- scrolling mobile page places with map ([432b451](https://github.com/italia/design-scuole-pagine-statiche/commit/432b451b892a662ecf2e2c1d9143fb3274fdd7a2)) +- update service data element ([#37](https://github.com/italia/design-scuole-pagine-statiche/issues/37)) ([b6a346a](https://github.com/italia/design-scuole-pagine-statiche/commit/b6a346a517f81810ed767917fb4f600e63c20b17)) +- wrong data-element ([ffb9c8e](https://github.com/italia/design-scuole-pagine-statiche/commit/ffb9c8e420224a7ea17a46f236fb6878c0f9cdc2)) ### Features -* add note legali in footer with data-elements ([7f85e2d](https://github.com/italia/design-scuole-pagine-statiche/commit/7f85e2de9a7c2d23009619d52006d3671394ce49)) -* add sitemap ([c68cf17](https://github.com/italia/design-scuole-pagine-statiche/commit/c68cf178625bdb7758a597798af6248c6dcc3b7d)) - - +- add note legali in footer with data-elements ([7f85e2d](https://github.com/italia/design-scuole-pagine-statiche/commit/7f85e2de9a7c2d23009619d52006d3671394ce49)) +- add sitemap ([c68cf17](https://github.com/italia/design-scuole-pagine-statiche/commit/c68cf178625bdb7758a597798af6248c6dcc3b7d)) # [2.2.0](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.1.3...v2.2.0) (2023-03-03) - ### Bug Fixes -* a11y issues ([62c25c2](https://github.com/italia/design-scuole-pagine-statiche/commit/62c25c29e9c1ac3d2bffa0b8839643ddbc3ac72a)), closes [#223](https://github.com/italia/design-scuole-pagine-statiche/issues/223) [#222](https://github.com/italia/design-scuole-pagine-statiche/issues/222) [#219](https://github.com/italia/design-scuole-pagine-statiche/issues/219) [#218](https://github.com/italia/design-scuole-pagine-statiche/issues/218) [#215](https://github.com/italia/design-scuole-pagine-statiche/issues/215) [#213](https://github.com/italia/design-scuole-pagine-statiche/issues/213) -* secondary nav items ([#30](https://github.com/italia/design-scuole-pagine-statiche/issues/30)) ([787133f](https://github.com/italia/design-scuole-pagine-statiche/commit/787133f61fab1b59975536e6c286dea90362fd72)) -* change headings ([#35](https://github.com/italia/design-scuole-pagine-statiche/pull/35)) ([787133f](https://github.com/italia/design-scuole-pagine-statiche/commit/5ac323686345766129a99303b014a7410a1c16ba)) - +- a11y issues ([62c25c2](https://github.com/italia/design-scuole-pagine-statiche/commit/62c25c29e9c1ac3d2bffa0b8839643ddbc3ac72a)), closes [#223](https://github.com/italia/design-scuole-pagine-statiche/issues/223) [#222](https://github.com/italia/design-scuole-pagine-statiche/issues/222) [#219](https://github.com/italia/design-scuole-pagine-statiche/issues/219) [#218](https://github.com/italia/design-scuole-pagine-statiche/issues/218) [#215](https://github.com/italia/design-scuole-pagine-statiche/issues/215) [#213](https://github.com/italia/design-scuole-pagine-statiche/issues/213) +- secondary nav items ([#30](https://github.com/italia/design-scuole-pagine-statiche/issues/30)) ([787133f](https://github.com/italia/design-scuole-pagine-statiche/commit/787133f61fab1b59975536e6c286dea90362fd72)) +- change headings ([#35](https://github.com/italia/design-scuole-pagine-statiche/pull/35)) ([787133f](https://github.com/italia/design-scuole-pagine-statiche/commit/5ac323686345766129a99303b014a7410a1c16ba)) ### Features -* add new `data-element`s ([5ac3236](https://github.com/italia/design-scuole-pagine-statiche/commit/5ac323686345766129a99303b014a7410a1c16ba)) -* templates index update ([#34](https://github.com/italia/design-scuole-pagine-statiche/issues/34)) ([d3034fb](https://github.com/italia/design-scuole-pagine-statiche/commit/d3034fb299179a205b016c58ac67d79c4558e8fa)) - - +- add new `data-element`s ([5ac3236](https://github.com/italia/design-scuole-pagine-statiche/commit/5ac323686345766129a99303b014a7410a1c16ba)) +- templates index update ([#34](https://github.com/italia/design-scuole-pagine-statiche/issues/34)) ([d3034fb](https://github.com/italia/design-scuole-pagine-statiche/commit/d3034fb299179a205b016c58ac67d79c4558e8fa)) ## [2.1.3](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.1.2...v2.1.3) (2022-11-30) - ### Bug Fixes -* header icon ([63c113d](https://github.com/italia/design-scuole-pagine-statiche/commit/63c113dd4699656c04259df0cc251bc3a3546e5f)) -* secondary nav items ([aba434a](https://github.com/italia/design-scuole-pagine-statiche/commit/aba434a02f683f9069dfeca9113843c259c03380)) -* various fixes to align design to theme - - +- header icon ([63c113d](https://github.com/italia/design-scuole-pagine-statiche/commit/63c113dd4699656c04259df0cc251bc3a3546e5f)) +- secondary nav items ([aba434a](https://github.com/italia/design-scuole-pagine-statiche/commit/aba434a02f683f9069dfeca9113843c259c03380)) +- various fixes to align design to theme ## [2.1.2](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.1.1...v2.1.2) (2022-10-06) - ### Bug Fixes -* add link to card name ([21e8205](https://github.com/italia/design-scuole-pagine-statiche/commit/21e82059ab3c7338f15c949d3a97e7101a5b8d0d)) -* correct gradient svg ([99ac85f](https://github.com/italia/design-scuole-pagine-statiche/commit/99ac85f4e2d383c69903d31032c4cce0502a0670)) - - +- add link to card name ([21e8205](https://github.com/italia/design-scuole-pagine-statiche/commit/21e82059ab3c7338f15c949d3a97e7101a5b8d0d)) +- correct gradient svg ([99ac85f](https://github.com/italia/design-scuole-pagine-statiche/commit/99ac85f4e2d383c69903d31032c4cce0502a0670)) ## [2.1.1](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.1.0...v2.1.1) (2022-09-08) - ### Bug Fixes -* **core:** missing text-decoration bug ([8a67352](https://github.com/italia/design-scuole-pagine-statiche/commit/8a67352df340a43c4267b585989f24a417bf7796)) -* **core:** navigation :hover state ([16a6fee](https://github.com/italia/design-scuole-pagine-statiche/commit/16a6feee752ee9c2f266a4e4c55ab21c967d6f58)) - - +- **core:** missing text-decoration bug ([8a67352](https://github.com/italia/design-scuole-pagine-statiche/commit/8a67352df340a43c4267b585989f24a417bf7796)) +- **core:** navigation :hover state ([16a6fee](https://github.com/italia/design-scuole-pagine-statiche/commit/16a6feee752ee9c2f266a4e4c55ab21c967d6f58)) # [2.1.0](https://github.com/italia/design-scuole-pagine-statiche/compare/v2.0.0...v2.1.0) (2022-07-28) - ### Bug Fixes -* **core:** accessibility ([d1ec240](https://github.com/italia/design-scuole-pagine-statiche/commit/d1ec2406281679e0fed4efbf8b4c31f12da2be33)) - - - +- **core:** accessibility ([d1ec240](https://github.com/italia/design-scuole-pagine-statiche/commit/d1ec2406281679e0fed4efbf8b4c31f12da2be33)) diff --git a/README.md b/README.md index dea235a6..b8f1adc4 100755 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Buon lavoro! ## Come iniziare -Per utilizzare i template del sito scolastico all'interno del tuo progetto, è sufficiente riutilizare il codice HTML presente nella cartella [build](https://github.com/italia/design-scuole-pagine-statiche/tree/main/build). +Per utilizzare i template del sito scolastico all'interno del tuo progetto, è sufficiente riutilizare il codice HTML presente nella cartella [build](https://github.com/italia/design-scuole-pagine-statiche/tree/main/build). Inizia scaricando le dipendenze esterne del progetto, utilizzando uno dei seguenti comandi: @@ -49,6 +49,7 @@ Infine, nel documento sono contenute alcune indicazioni per la migrazione e/o ri [Vai al documento di architettura dell'informazione (ODS 337)](https://designers.italia.it/files/resources/modelli/scuole/adotta-il-modello-di-sito-scolastico/definisci-architettura-e-contenuti/Architettura-informazione-sito-scuole.ods) ## Come contribuire + Vorresti dare una mano contribuendo allo sviluppo del progetto? Se non l'hai già fatto, inizia spendendo qualche minuto per approfondire la tua conoscenza sul [documento di architettura dell'informazione (ODS 337)](https://designers.italia.it/files/resources/modelli/scuole/adotta-il-modello-di-sito-scolastico/definisci-architettura-e-contenuti/Architettura-informazione-sito-scuole.ods) e fai riferimento alle [indicazioni su come contribuire](https://github.com/italia/design-scuole-wordpress-theme/blob/main/CONTRIBUTING.md). diff --git a/README_CI.md b/README_CI.md new file mode 100644 index 00000000..43e85a8d --- /dev/null +++ b/README_CI.md @@ -0,0 +1,41 @@ +# CI & GitHub Pages — Quick Setup for this repo + +This repo (fork) uses GitHub Actions to build and publish previews and the main site. + +Essentials + +- Repo that should run Actions: `RedTurtle/design-scuole-pagine-statiche` (workflows guard on repository name). +- Previews: pushed branches run `preview-deploy.yml` and publish to `gh-pages/previews//`. +- Production: `deploy-gh-pages.yml` publishes `dist/` to GitHub Pages when `main` is pushed. +- Cleanup: `cleanup-previews.yml` removes `previews//` from `gh-pages` when the PR is merged. + +What to enable in GitHub settings + +1. Settings → Actions + - Ensure Actions are enabled for your fork (Allow all actions or allow local only). +2. Settings → Pages + - Source: use GitHub Actions (the workflows publish to `gh-pages` branch). + +How previews work (PR workflow) + +- When you push a branch to the fork, the `preview-deploy.yml` workflow runs (only in `RedTurtle/...`). +- It builds the site (`pnpm build`) and publishes `dist/` under `gh-pages/previews//`. +- The workflow comments the PR with the preview URL — paste it in the upstream PR description if needed. +- When the PR is merged, `cleanup-previews.yml` removes that preview directory. + +Local testing + +```bash +pnpm install +pnpm build +pnpm preview +# open http://localhost:5173/index.html +``` + +Security notes + +- All workflows are guarded to run only if `github.repository == 'RedTurtle/design-scuole-pagine-statiche'`. +- We do not push changes to the upstream `italia/...` repository. +- Secrets are not exposed to upstream PRs; workflows run in the context of the fork. + +If you want changes to the trigger rules (e.g. restrict which branch prefixes create previews), tell me and I'll update `preview-deploy.yml` accordingly. diff --git a/docs/01-cosa-si-usa.md b/docs/01-cosa-si-usa.md new file mode 100644 index 00000000..19f10648 --- /dev/null +++ b/docs/01-cosa-si-usa.md @@ -0,0 +1,20 @@ +# Cosa si usa + +## Obiettivo + +Setup semplice e adatto a profili junior per creare pagine statiche del modello Scuole. + +## Stack + +- HTML statico (una pagina = un file `.html` in `src/pages/`) +- JavaScript separato (`src/js/main.js` + `src/js/pages/*`) +- CSS in `src/styles/` +- Vite come dev server e build tool multipagina +- Dev Kit Italia (`@italia/dev-kit-italia`) per i Web Components +- GitHub Actions per CI e deploy su Pages + +## Perché questa scelta + +- niente Handlebars/webpack da imparare +- avvio rapido locale +- output finale statico e pubblicabile facilmente su GitHub Pages diff --git a/docs/02-come-si-usa.md b/docs/02-come-si-usa.md new file mode 100644 index 00000000..d73932b4 --- /dev/null +++ b/docs/02-come-si-usa.md @@ -0,0 +1,53 @@ +# Come si usa + +## Prerequisiti + +- Node.js 24 (gestito con `nvm`) +- pnpm 10+ + +## Primo avvio + +```bash +nvm use +pnpm install +pnpm dev +``` + +Il dev server si apre su `http://localhost:5173` con la pagina indice. + +## Comandi utili + +```bash +pnpm run lint:html # valida gli HTML +pnpm run lint:js # linta il JS +pnpm run lint:css # linta il CSS +pnpm run format:check # controlla la formattazione con Prettier +pnpm run build # build di produzione in dist/ +pnpm run preview # anteprima del build +``` + +## Struttura sorgente + +``` +src/ +├── index.html # pagina indice con link alle pagine +├── pages/ +│ ├── index.html # pagina di test rapida +│ └── servizio.html # esempio pagina servizio +├── js/ +│ ├── main.js # import CSS/font/componenti Dev Kit +│ └── pages/ +│ ├── index.js # JS specifico per index +│ └── servizio.js # JS specifico per servizio +└── styles/ + └── main.css # stili del progetto +``` + +## Output build + +``` +dist/ +├── index.html # pagina indice +├── pages/ # pagine HTML con path asset corretti +└── assets/ # JS, CSS e font bundlati +``` diff --git a/docs/03-come-si-sviluppa.md b/docs/03-come-si-sviluppa.md new file mode 100644 index 00000000..57efd22a --- /dev/null +++ b/docs/03-come-si-sviluppa.md @@ -0,0 +1,36 @@ +# Come si sviluppa + +## Flusso consigliato + +1. Crea un branch da `main`. +2. Modifica i file HTML in `src/pages/` e il JS in `src/js/pages/`. +3. Verifica in locale (`pnpm dev`, `pnpm run lint:html`, `pnpm run build`). +4. Apri Pull Request — parte automaticamente la preview del branch. +5. Fai merge su `main`. + +## Aggiungere una nuova pagina + +1. Crea `src/pages/nuova-pagina.html` — Vite la raccoglie automaticamente come entry point. +2. Crea `src/js/pages/nuova-pagina.js` con almeno: + ```js + import '../main.js'; + ``` +3. Aggiungi il ` + ``` +4. Aggiungi il link in `src/index.html`. + +## Regole pratiche + +- una pagina per file +- JS separato per pagina +- naming chiaro dei file (`home.html`, `servizio-x.html`, ecc.) +- non modificare `dist/` a mano — è generato dal build + +## Strategia di migrazione dal repo storico + +- partire dalle pagine prioritarie +- creare versione HTML base +- sostituire blocchi UI con Web Components Dev Kit +- validare visivamente e con lint HTML diff --git a/docs/04-actions-github.md b/docs/04-actions-github.md new file mode 100644 index 00000000..d0524c9e --- /dev/null +++ b/docs/04-actions-github.md @@ -0,0 +1,55 @@ +# Actions GitHub + +## Chi builda + +Build e deploy vengono eseguiti da **GitHub Actions** su runner `ubuntu-latest`. +È GitHub (non una persona) che esegue i job quando parte un trigger. + +## Workflow presenti + +### 1) Lint (`.github/workflows/lint.yml`) + +Eseguito su ogni **pull request**. + +Fa: +- format check con Prettier +- lint HTML (`pnpm run lint:html`) +- lint JS (`pnpm run lint:js`) +- lint CSS (`pnpm run lint:css`) + +### 2) Deploy Pages (`.github/workflows/pages.yml`) + +Eseguito **manualmente** da GitHub (`workflow_dispatch`). + +Fa: +- build del progetto +- upload artifact statico (`dist/`) +- deploy su GitHub Pages (environment `github-pages`) + +### 3) Preview (`.github/workflows/preview.yml`) + +Eseguito su ogni **pull request** (open, sync, close). + +Fa: +- **deploy**: build + push di `dist/` in `previews//` sulla branch `gh-pages` +- **commento PR**: posta o aggiorna un commento con l'URL della preview +- **cleanup**: alla chiusura della PR rimuove la cartella preview da `gh-pages` + +### 4) CodeQL + +Gestito dal **default setup** di GitHub (Settings → Code security → Code scanning). +Nessun file di workflow nel repo — gira automaticamente su push/PR su `main` e con schedule settimanale. + +### 5) Generate release (`.github/workflows/publish-release.yml`) + +Eseguito su tag `v2*`. + +Fa: +- build e zip del progetto +- pubblicazione GitHub Release con allegato zip + +## Note + +- Il **deploy su Pages è manuale**: si lancia a mano da GitHub Actions quando si vuole pubblicare. +- Le **preview dei branch** sono automatiche su ogni PR e si trovano a `https://.github.io//previews//`. +- La branch `gh-pages` viene gestita dai workflow — non modificarla a mano. diff --git a/docs/05-tecnologie-riferimenti.md b/docs/05-tecnologie-riferimenti.md new file mode 100644 index 00000000..aa32c311 --- /dev/null +++ b/docs/05-tecnologie-riferimenti.md @@ -0,0 +1,21 @@ +# Tecnologie e riferimenti + +## Tecnologie + +- HTML5 +- JavaScript ES Modules +- Vite +- Dev Kit Italia (Web Components) +- pnpm +- GitHub Actions + +## Riferimenti online + +- Design scuole pagine statiche: +- Dev Kit Italia repo: +- Dev Kit Italia docs: +- Vite docs: +- pnpm docs: +- nvm: +- GitHub Actions docs: +- GitHub Pages docs: diff --git a/docs/06-template-system.md b/docs/06-template-system.md new file mode 100644 index 00000000..4032034b --- /dev/null +++ b/docs/06-template-system.md @@ -0,0 +1,128 @@ +# Sistema di template + +Ogni elemento riutilizzabile di una pagina (header, footer, card, sezioni) è definito +come un elemento [`