Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://prettier.io/docs/en/ignore.html

# Ignore Vocabulary files (formatting handled upstream)
src/vocabulary/
8 changes: 8 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://prettier.io/docs/en/options.html#print-width
printWidth: 79

# https://prettier.io/docs/en/options.html#bracket-line
bracketSameLine: true

# https://prettier.io/docs/en/options.html#single-attribute-per-line
singleAttributePerLine: true
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ Once changes are implemented here, they need to be updated within the `/chooser`

Final production changes are deployed within vocabulary-theme Releases, updated within [`index-dev-env`][index-dev-env], and finally deployed to `index__stage` and then `index__prod` environments; going LIVE at `https://creativecommons.org/chooser`.


## Setup
1. open the `src/index.html` file within a browser to view the Chooser.

[cc-legal-tools-app]: https://github.com/creativecommons/cc-legal-tools-app
[cc-legal-tools-data]: https://github.com/creativecommons/cc-legal-tools-data
[index-dev-env]: https://github.com/creativecommons/index-dev-env
Expand All @@ -65,11 +61,34 @@ Final production changes are deployed within vocabulary-theme Releases, updated
[vocabulary-theme]: https://github.com/creativecommons/vocabulary-theme


### Setting up the Project

For information on learning and installing the prerequisite technologies for this project, please see [Foundational technologies — Creative Commons Open Source][found-tech].

[found-tech]: https://opensource.creativecommons.org/contributing-code/foundational-tech/

1. open the `src/index.html` file within a browser to view the Chooser.

### Format with Prettier

Run the following command to format files with Prettier:

```shell
docker compose run node prettier --write src/
```

```shell
## Or alternatively, if docker compose run is slow to run
docker compose up --detach
docker compose exec node prettier --write src/
docker compose down
```

## Structure

The initial markup is rendered via the `index.html` file. Visual display is derived from the `style.css` rules. Styles extend from `src/vocabulary`.

On initlialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.
On initialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.

The main `tool` recommendation content is pulled via the appropriate `<template>` markup located within HTML. Additional information for the marking formats is also sourced from these `<template>` elements and the contents of the `Attribution Details` fields.

Expand Down
6 changes: 6 additions & 0 deletions dev/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://docs.docker.com/engine/reference/builder/

# https://hub.docker.com/_/node
FROM node:bookworm-slim

RUN npm install --global prettier
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: chooser
services:
node:
build:
context: .
dockerfile: dev/node/Dockerfile
# Continue running until shutdown (this allows docker compose exec which is
# much faster than docker compose run)
# Thank you: https://serverfault.com/a/1084975
command: /bin/sh -c "
trap 'exit' TERM;
echo 'Run the following command to format files with Prettier:';
echo ' docker compose exec node prettier --write src/';
while true; do sleep 1; done
"
container_name: cc-chooser-node
volumes:
# Mount repository to working directory
- "./:/opt"
working_dir: /opt