Skip to content

refactor chooser to be more exacting, simplified, and maintainable #570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 136 commits into
base: main
Choose a base branch
from

Conversation

possumbilities
Copy link
Contributor

@possumbilities possumbilities commented Apr 1, 2025

Description

The overall goal here is to make the Chooser smaller, clearer, and more easily maintained, while allowing fresh room to implement changes as needed.

Metrics

npm audit

old dependecies : 2748 dependencies (179 vulnerabilities (10 low, 110 moderate, 41 high, 18 critical))

--- ~# lines of code
old JS (and fam): 32,515
old CSS (and fam): 7118
SUBTOTAL: 39,633
TOTAL (with deps): 260,885

refactor dependencies: 1 (Vocabulary)

--- ~# lines of code
refactor JS: 621
refactor CSS: 369
refactor HTML: 811
SUBTOTAL: 1801
TOTAL (with deps): 4535
  • removed 31,894 lines from core JS
  • removed 250,412 lines from JS core + deps
  • old JS (and fam): ~32,515 | refactor JS: ~621 | ~98.1% reduction in JavaScript
  • old core: ~39,633 | refactor core: ~1801 | ~95.45% reduction in core codebase
  • (old core + deps): ~260,885 | refactor (core + deps): ~4535 | ~98.26% reduction in core codebase + deps
  • overall code footprint is now 57.52 times smaller!
    • 🌍 If the refactored codebase's footprint was Earth, then old codebase's footprint would be Neptune, since Neptune's volume is 58 times larger than Earth (meaning you could fit 58 Earths within Neptune).

Note: most of the above metrics were gathered originally via the following commands in the correct directories:

find . -name '*.js' | xargs wc -l
find . -name '*.json' | xargs wc -l
find . -name '*.vue' | xargs wc -l
find . -name '*.css' | xargs wc -l
find . -name '*.scss' | xargs wc -l
find . -name '*.sass' | xargs wc -l
find . -name '*.html' | xargs wc -l

Technical details

  • tool contents are dynamically pulled via JS through the use of <template> elements
  • marking formats are dynamically pulled via JS through the use of JS string interpolation and <template> elements
  • overall approach can introduce more Web Component abstraction behavior, including binding all marking formats to only <template>
  • styling .css markup is bound to the chooser-page context and intended to be utilzied as an @layer @import within downstream implementation alongside and dependent upon vocabulary
  • JS is broken up into relevantly named functions that control everything from stepper flow, recommendation rendering, to marking format rendering; relevant watchers are then set to update state when changes happen within certain elements. When updates occur the rawStatePaths are compared to the current state to verify if a tool has been matched, if so the relevant tool is recommended, if not the tool remains set to unknown
  • There is now a default prompt indicating fields have not been completed yet.
  • The form's dynamic behavior provides recommendations when conditions are met, which means the form needs no formal submission or "done" button action
  • User's can now more easily move backwards in the stepper flow, or change their license selections, with less steps and less friction.
  • Important fieldsets for those unfamiliar with the tools, which need help choosing, are now required prior to a tool recommendation; these include the checkbox fields asserting users are aware of what they are doing prior to utilizing the tool.
  • the tabbed interface now relies upon <details> and <summary, rather than more bespoke UI/UX. This comes with a lot of given affordances that don't need to be implicitly set.
  • The help section has been moved to a more semantic location, that is also more visually helpful to a user during "unknown" and "default" states.
  • the help section has been modified to utilize <details> and <summary> elements, rather than non semantic, non accessible "links" which open popup modals.
  • A variety of improvements for smaller viewports, making the interface more compact, and more usable where possible
  • fields have better defaults, marking formats carry defaults over to give clearer indication of their purpose and rendering.
  • Tool recommendation has clearer wording to indicate that it is a recommendation
  • Tool recommendation has UX improvements to allow the design to better stand out, and increase clarity and contrast between itself and the marking section
  • the marking section has had its semantics updated to be a child of the tool recommendation, rather than a sibling showing a better relationship between the two.
  • Chooser can be embedded within vocabulary-theme, which removes the need to update the global header or global footer components anymore, it will instead inherit from the theme itself as changes are dynamically made within WordPress
  • refines stepper copy to more smoothly move through steps with less repetition, increasing clarity
  • provides a default pathway initially, user can change, but reduces friction for returning users who don't need help.
  • utilizes .svgs where feasible within interface
  • tool icons within marking formats now all pull from the correct mirrors.creativecommons.org address (in the old chooser some formats pull from the chooser's codebase instead)
  • use of user facing language of license has been converted more generally to tool wherever feasible, same with codebase.
  • transition away from the use of scss/sass, move to native non-compiled CSS and utilize more current supported features

Screenshots

🖼 default state

effective-xylophone-jv4p944457w2ppvv-8080 app github dev_

🖼 license rec state - don't need help

effective-xylophone-jv4p944457w2ppvv-8080 app github dev_ (1)

🖼 CC0 rec state - don't need help

effective-xylophone-jv4p944457w2ppvv-8080 app github dev_ (2)

🖼 license rec state - need help

effective-xylophone-jv4p944457w2ppvv-8080 app github dev_ (3)

🖼 need help section - open Screen Shot 2025-04-03 at 9 20 40 AM

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main or master).
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

For the purposes of this DCO, "license" is equivalent to "license or public domain dedication," and "open source license" is equivalent to "open content license or public domain dedication."

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

… for later comparison tracking on choice pathway selection
Copy link

netlify bot commented Apr 1, 2025

Deploy Preview for creativecommons-chooser failed.

Name Link
🔨 Latest commit e8bed13
🔍 Latest deploy log https://app.netlify.com/sites/creativecommons-chooser/deploys/67ec1cfc55e26c00070e53d2

@possumbilities possumbilities moved this to In review in possumbilities Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
1 participant