Skip to content
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

Develop #34

Closed
wants to merge 49 commits into from
Closed

Develop #34

wants to merge 49 commits into from

Conversation

pvspain
Copy link
Contributor

@pvspain pvspain commented Aug 10, 2023

Hi Dave, long time no PR! I hope you're keeping well?

Sorry to dump a truckload on you. I was trying to submit a cohesive and complete change, but it just kept growing. I've rebased all my commits to reduce the number of changes to you need to review and QA, but there is still a lot!

Here are the big ticket items:

  • Migrated the code to ES6 and ESM modules
  • Wrote a pure NodeJS demo/test sample in the dev folder
  • Switched to ViteJS for bundling and serving of dev
  • Added solution support feature - test, reveal, clean, reset of cells, clues and crossword
  • Extended crossword definition to support 'answer' and 'solution' properties for each clue
  • Solution support features added to dev
  • Added (optional) crossword-clues DOM element that syncs with crossword-grid DOM element
  • Added spell checking to project
  • Restyled crossword to use CSS Grid and Flexbox and made responsive
  • Parameterised CSS to simplify changing look-and-feel.
  • Renamed and re-organised code to follow MVC pattern artefacts
  • Added generalised pub-sub to controller (was crossworddom) and publishing all state change events.
  • Added a lot of documentation
  • Reworked and extended README and added doco links
  • Ticked off most of the TODOs in the README

revert version

tweak markup

Address lint issues and convert CellMap to class

Address some lint issues

Branch for conversion to ES modules.
Compiling but no crossword visible in sampleapp.
eslint error: "Window is not defined"  src/index.js:13:3

Eslint not working without mjs file suffix on sources.
Dev server (npm start) failing with mjs suffix on src/index.mjs.
Broken broken broken.
Simple node server example.
wip. Framing page displaying.
TODO: wire up crossword elements.

*package.json*

- Add *.less to prettier filetypes.

*crossword.less*

- Tweak revealed and incorrect css - don't process pointer events.
- Cell styles working.

*crossworddom-helpers.js*

- Finished implementation of revealCell.
- Add implementations for testCell and testClue.

*crossworddom.js*

- Add accessor gridElement.
	- can't access private class property in updateCrosswordFontSize, and better encapsulation!
- Add helper function incorrectElement.
- Implement testCurrentClue, testCrossword.
- Add cellIncorrect element inside #createCellDOM

Ready to test new features!

wip.

Rename 'insertStrAt' as 'replaceStrAt'.
Add extensive tests for 'replStrAt'.

*crossworddom-helpers.js*

- Export resetCell and resetClue
- Sort module exports

*crossworddom.js*

- Implement resetClue, resetCrossword.
- Sort module imports.

css fixup
- Adapt memoize() to work for functions _without_ boolean, string or number arguments. Attach random ids to cached objects
-  Add utility toHexString(). Unfortunately this doesn't work for circular (self-referential) objects - like ours!

*crossworddom.js*

- Add name consts for keycode values to  improve code readability.
- Add trace for clue.code in currentClue setter.
 *crosswords.less*

 - Remove bottom,right style attributes. Irrelevant when height,width = 100% (?)

*crossworddom-helpers.js*

- Add hideElement, showElement

*crossworddom.js*

- HideElement calls added to event handlers for BACKSPACE, DEL and KeyPress
Add documentation for helpers# This is a combination of 5 commits.

*helpers.js*

- Add doc for assert()

*crossworddom.js*

- A few non-functional tweaks!
- Refactored TAB key processing - removed loop.

Add api test buttons to sample app. Not working. wip.

Add doc for memoize.

Add crosswordDom to $scope.
Change references in new handlers.
Not working

change event binding syntax
…nts.

- Spell checking (en_GB) for all source files.
- Add JsDoc documentation for significant methods/functions and many helper functions.

*Files*

- src/celldom-helpers.js -> src/cell-element-helpers.js
- src/compile-clue.js -> src/clue-model.js
- src/compile-clue.specs.js -> src/clue-model.specs.js
- src/compile-crossword.js -> src/crossword-model.js
- src/compile-crossword.specs.js -> src/crossword-model.specs.js
- src/crossworddom.js -> src/crossword-controller.js
- src/crossworddom-helpers.js -> src/crossword-controller-helpers.js
- src/celldom-helpers.js -> src/cell-element-helpers.js

*src/crossword-controller.js*

- CrosswordDOM ->  CrosswordController
- #crosswordGridElement ->  #crosswordView
- gridElement -> crosswordView

- Fix bug in #onWindowResize()
  - crosswordView must be extracted from DOM in window event handler

*src/crossword-model.js*

- buildCellArray2D() -> buildCellGrid()
- compileCrossword() -> newCrosswordModel()
- crosswordDefinition -> jsonCrossword
- clueDefinitions -> jsonClues

*clue-model.js*

-  compileClue() -> newClueModel()
Renamed folder node-sample -> sample-node

order script targets alphabetically

Add cspell to package.json

- Add spell-checking to project.
- Fix remaining typos!
- Bump webpack version to address critical issue.
- Prettify crossword samples
*README.md*

- Modify the example code for initialising the package.
- Add example code for using the new API methods.
- Add spell-checker instructions to the Developer Guide.
- Add Design Overview section - reference for MVC pattern.
-  Tweak TODOs

Renamed folder node-sample -> sample-node.
wip.

Fix typos, md formatting
- Re-installed packages.
  - webpack updated for high vulnerability
…ethods.

Add spelling exceptions.
Expand replaceStrAt() to support negative indexes (relative to end).
Add solution support methods cleanCell(), cleanClue().

*README.md*

- Tweak comments in code blocks.
- Add missing keystrokes to _Keyboard Functionality_.

*cspell.json*

- Remove misspelled testing words.

*package-lock.json*

- Update packages

*src/clue-model.specs.js*

- Flag misspelled words for cspell.

*src/helpers.js*

- Extend replaceStrAt() to support negative index values, a la `string.slice()`.

*src/helpers.specs.js*

- Add extra tests for negative index values in `replaceStrAt()`.

*README.md*

- Add documentation for new API methods cleanCurrentClue and cleanCrossword

*src/crossword-controller-helpers.js*

- Extract common logic as setCellText()
-  Change `testCell()` and `testClue()` to return boolean result of test
- Add `cleanCell()` and `cleanClue()`.

*src/crossword-controller.js*

- Add `cleanCurrentClue()` and `cleanCrossword()`
Rename 'sample-node' to 'dev'
Update README with dev server instructions
Package version updates

Add request tracing.

Fix references to sample directories.
Refactor server.js. wip.

- rename `sample-node` to `dev`

*package.json*

- add `nodemon` for live reload of node app on source change.
- extend all **scripts** targets to cover `dev` folder.
- add `"dev"` **scripts** target to start a live-reload dev server.

*dev/server.js*

- a minimal node dev server
- dynamic `.less` file compilation
- static file caching

*sample/sampleapp.js*

- shortened variable names

*src/crossword-controller.js*

- add `tracing` call to control logging from within this file.
- fix: re-add `assert` to imports.

*src/crossword-model.js*

- revert function name to `compileCrossword`

*src/helpers.js*

- add `tracing` function to toggle logging form other source files.

*src/index.js*

- revert to `compileCrossword` for clarity of intent

*README.md*

- Rework and expand _Quickstart_ instructions.
  - Add instruction to run Angular sample
- Add instructions for development server to _Developer Guide_.

Add 'spell:changed' script  to package.json.
Minor README tweaks.

Add dev/favicon.ico

- Add nodemon config (to watch dev/index.html) .
- Add dev/crosswords.js (package public API)

- Add favicon.ico and crosswords.js.
 - Add API button stubs.

Add API button stubs (broken)

wip.

wip

Added yaml crossword.
Add helpers.js (tracing).
wip.

package lock tweaks
Add esm module

conversion to es6 modules.wip

Tests passing.

Add solution querying support. Change from simple javascript devserver to ViteJS and ESM.

Fixup index.mjs reference
Add type module to package.json for ESM.
Add test to incuded dirs for lint, prettier, spell.
Recreate ESM version of require to import JSON crossword definitions.
Commented alternative approach using JSON.parse with embedded await!

modified:   test/crossword-model.specs.mjs

Move unused imports into commented section

modified:   webpack.config.js

Modify for ESM

- css ; font sizes changed to 'rem' from 'em' to avoid 'compounding' issue: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
- Converted dev server to ESM

Rename compileCrossword to newCrosswordModel
API (crossowrds.js) maintains 'compileCrossword'

**modified:   .eslintrc.yml**
- Changed test script spec for ESM (*.mjs)
**deleted:    dev/server.js**
- Now using `vite` as dev server
**modified:   package-lock.json**
**modified:   package.json**
- Add **viteJS** as dev server and bundler
- Change `dev` script entry to use `vite`
- `chai` moved back to dev dependency as a result of `.eslintrc.yml` change
- Remove `nodemon` with change to `vite` - vite reloads on source change.
**modified:   src/crossword-controller.mjs**
- Add `trace` call for contructor
**modified:   src/crossword-model.mjs**
- Add `trace` call for `newCrosswordModel`

**modified:   dev/index.html**
- Add include of index.js for startup logic
**new file:   dev/index.js**
- Startup logic
**modified:   dev/crosswords.js**
- Convert to ESM
**modified:   src/crossword-controller.mjs**
- Working through seerver/client logic for event handlers. wip.

**deleted:    dev/crosswords.css**
- Dynamically generated by `vite` now
**modified:   dev/index.html**
- Trying onClick setting when DOM ready. Event is firing but `this` and window.controller are not aligned in handler??
**modified:   dev/index.js**
- Move onCLick setting over to index.html
**modified:   package.json**
- Add new dev targets: preview and build
**modified:   sample/sampleapp.js**
- Adjust event handler names. Not working. Crossword grid is HUGE now :(
**modified:   src/crossword-controller.mjs**
- Use `addClass` and new `addClasses` wherever class names set.
- Lots of instrumentation in `revealCurrentCell`. Not working.
**modified:   src/crossword-model.mjs**
- Variable name corrected. nfc.
**modified:   src/crosswords.less**
- Change variables to less-style
- Change font-sizes unit from `rem` back to `em`. Reduce the number of variables.
- Disable  `.cwcell:after` styling since cells are not square now!
**modified:   src/helpers.mjs**
- Add `addClasses`

- Controller event handlers are now firing.
- Issues remain in controller code - current cell index seems off when event fires?
**modified:   dev/crosswords.js**
- Add helpers to export
**modified:   dev/index.html**
- Drop jQuery import
- Drop crosswords.js import - imported indirectly via index.js
**modified:   dev/index.js**
- Add document `DOMContentLoaded` for post-DOM-load logic
- Add event listeners (finally working!!)
**modified:   src/crossword-controller-helpers.mjs**
- Replace intances of `replStrAt` with `setLetter` so we get padding for null/undefined clue.answers
**modified:   src/crossword-controller.mjs**
- Add elementEventHandlers
- TODO: Do we still need all the bind() calls?

**modified:   src/crossword-controller-helpers.mjs**
- Add trace messages to `revealCell`
- Test cell argument to `setCellText`
- Extract inner function `adjustClue`
- Remove styling changes from `setCellText` - outside scope of method!
**modified:   src/crossword-controller.mjs**
- Fix bugs in `revealedElement` and `incorrectElement` -> div index is conditional on clue label in cell
- Add context to `currentCell` and `testCurrentClue` trace message
- Fix bugs in all test/clean/clear/reveal api helper method calls -> controller argument was missing.

Replace `.map()` with `.foreach()` where resultant array is not used.

**modified:   src/clue-model.mjs**
- Bugfix: `clue.solution` normalisation regex was not replacing all instances.
- `clue.answer` normalisation replaces all illegals with spaces and pads to `answerLength`
- Undefined `clue.answer` get padded to `answerLength`
**modified:   src/crossword-model.mjs**
- Tweak doc comments
- Add logic to validate clue solutions
- Add logic to allow for normalised ciue answers and clue solutions
**modified:   test/clue-model.specs.mjs**
- Add tests for normalisable clue answers and soultions
- Add test for undefined solution ('solution' field present but undefined value)
**modified:   test/crossword-model.specs.mjs**
- Add coherence tests for provided solution
- Add coherence tests for provided normalisable solutions

- Clue coherence testing sorted, but display bug introduced
  - answers going in wrong cells  :( WIP!
**modified:   dev/crosswords/ftimes_17095.json**
**modified:   dev/crosswords/ftimes_17095.yml**
**modified:   test/test-crosswords/ftimes_17095.json**
- Bugfix: Coordinates of clue 27d.
**modified:   dev/index.js**
**modified:   src/helpers.mjs**
- Case error in forEach.
**modified:   src/crossword-model.mjs**
- Add more context to exception text for clue coherence tests
**modified:   test/crossword-model.specs.mjs**
- Add test to validate all test crosswords.
- Adjust exception text for clue coherence tests

**modified:   dev/index.js**
**modified:   src/helpers.mjs**
- Fix case in calls to `array.forEach`
**modified:   dev/crosswords/ftimes_17095.json**
- Fix coordinates for 27d in ftimes crossword.

Bugfix in `testClue` and additional tracing
**modified:   dev/index.js**
- Sort element order (group, alphabetic-name)
**modified:   src/crossword-controller-helpers.mjs**
- Add more tracing
- Bugfix: `testClue` - remove short-circuit execution of `testCell`
**modified:   src/crossword-controller.mjs**
- Add more tracing

Bugfix: File-based-answer display. Git template.
new file:   .git-commit-template.txt
- Add a project git commit message template
modified:   README.md
- Add git commit message template installation instructions
modified:   dev/crosswords/ftimes_17095.json
- Add more test answers
modified:   cspell.json
- Add mispelled words in test crossword answers
modified:   src/clue-model.mjs
 - Relocate answer assignment in 'newClueModel' as its now
   dependent upon answer length for padding length
- Do not substitute spaces for illegals in solution normalisation,
  just delete. We want to fail if removing illegals shortens solution.
  This wll flag an exception for crossword setter.
modified:   src/crossword-model.mjs
 - Bugfix: 'newCrosswordModel' was clobbering existing cell value when
   no answer was defined for a clue.
modified:   test/clue-model.specs.mjs
- Add tests for undefined soution and normalised answers and solutions.
- Modify test to expect padded answers for short or undefined
  answers and solutions.
modified:   test/crossword-model.specs.mjs
- Add valid case for coherence test.
- Add valid test for coherence of normalised solutions.

Bugfix: test crossword. Add trace detail and tests
modified:   test/test-crosswords/ftimes_17095.json
- Bugfix: 25d coordinates
modified:   dev/crosswords/ftimes_17095.yml
- Regenerate YAML
modified:   src/crossword-controller-helpers.mjs
- Modify 'adjustClue' to return modified copy of clue.
modified:   src/crossword-model.mjs
- Add detail to error message for coherency error
modified:   test/crossword-model.specs.mjs
 - Add test to validate all test crosswords.

Bugfix: vertically displaced .cwcell-incorrect (displaced to row below)

Bugfixes: Broken crossword-level event handlers
modified:   README.md
- Tweak git commit template instructions
modified:   src/crossword-controller-helpers.mjs
- Commented cell-level trace messages to reduce noise levels in console
modified:   src/crossword-controller.mjs
- Bugfix: Remove trailing space in labels for 'clean-crossword'
          and 'reset-crossword'
- Re-order event handlers - sorted by (group, alphabetical label)
modified:   src/crossword-model.mjs
- Commented trace messages to reduce noise levels in console
Test CSS Grid layout
modified:   package.json
new file:   test/index.html

Moving CSS Grid layout into 'crosswords.less'.wip.

modified:   dev/index.html
- Change grid parent element id to 'crossword-grid'
modified:   dev/index.js
- Add browser styles reset CSS
modified:   src/crossword-controller.mjs
- Style current cell, so colour remains when grid loses focus
modified:   test/index.html
- Fix for grid dimensions to minimally contain cells

Move style files (css/less) into 'style' folder
deleted:    src/crosswords.less
new file:   style/crosswords.less
- Change grid parent element id to 'crossword-grid'
new file:   style/reset.css

Bug: Cells are added in row-order, but are being
dispayed with the rows displaying vertically? (i.e. as columns)

modified:   README.md
- Tweaked controller event descriptions to align with 'dev/index.js'
- Minor styling tweak elsewhere.
modified:   dev/index.js
- Added more documentation.
modified:   src/crossword-controller.mjs
- Add tracing to 'newCellElement' to validate divs are created in
  row order
modified:   style/crosswords.less
- Flipped declaration order of grid rows and columns to try to address
  display bug. No change :(

Fixed nesting
modified:   style/crosswords.less

Fixing css-grid-based crossword grid. wip.
modified:   dev/index.html
- Stripped back to minimal page and rebuilding
new file:   docs/img/css-flexbox-poster.png
new file:   docs/img/css-grid-poster.png
new file:   docs/styling.md
- Add CSS Grid and Flexbox reference documentation
modified:   src/crossword-controller.mjs
- Strip out rows from crossword view creation.
  The grid is created form styles
modified:   style/crosswords.less
- Strip out styles to essentials till gris is working.
  Ref to test/index.html (npm run cssgrid)
modified:   test/index.html
- Simplify page. Commented font attributes belong in input styles

modified:   .gitattributes
Add .png as binary file type

Grid base layout working well. Cell layers are wip.
modified:   dev/index.js
- Bugfix: validate return value of 'document.getElementById()'
modified:   src/crossword-controller.mjs
 - Change implementation of 'set currentClue()'.
   Preserve current cell if contained within new current clue.
   Otherwise set current cell to first cell of new current clue.
modified:   src/cell-element-helpers.mjs
 - Remove explicit setting of current cell in 'toggleClueDirection()'
modified:   style/crosswords.less
- Grid base layout working well. Cell layers are wip.

Fix: Clue label location.
modified:   src/crossword-controller-helpers.mjs
 - Disable font resizing on window scaling/resizing
modified:   style/crosswords.less
 - Correct clue label position by setting cell display to grid
   and justify and align cell-items to start.
 - Input hidden temporarily till grid appearnace sorted.
  - Grid row-line thickness is double column-line thickness. Why?

Tweaking sizes. Looking pretty good.
modified:   style/crosswords.less
- Cell and input dimensions are matched at this ratio of
  grid cell size : input font size
- Switched to 'large' font-size at crossword level

Group colours into a theme. Sizes are relative.
modified:   style/crosswords.less
- Add suffix 'color' to all color variables.
- Cell label positioned correctly.
  Needs a little padding top and left min.
  Currently label slightly overlaps W in cell text.
- Cell overlaps horizontal grid lines and container padding.

Style input focus
modified:   style/crosswords.less
Reintroduce header and buttons.
modified:   dev/index.html
- Revealed marker displaying properly
modified:   style/crosswords.less
- Add body background color to reduce brightness!
- Tweaked revealed size marker smaller
- Introduced display:grid to label and revealed
- Pushed label to top left and revealed to bottom right
- Fixed bug in incorrect diagonal bands
- Otherwise, incorrect is a mess. A full cell-width line of height 0.

Incorrect styling now working
All unneccesary styling removed
modified:   dev/index.html
modified:   style/crosswords.less

Remove unused elements. Word-separators visible
modified:   style/crosswords.less

Remove redundant code (updateCrosswordFontSize).
Crossword sizes all based on ems, so font size
adapts automagically.

modified:   src/crossword-controller-helpers.mjs
- Remove defintion of updateCrosswordFontSize.
modified:   src/crossword-controller.mjs
- Removed windowResize listener and all refs to
  updateCrosswordFontSize.
modified:   style/crosswords.less
- Modify transitions

Move first clue selection to end of constructor.
modified:   src/crossword-controller.mjs
- Remove 'onPageLoaded' event listener.
  Event occurs before controller is constructed.

modified:   cspell.json
- Add less filenames.
modified:   dev/index.css
- Add flexbox styling for body of dev/index.html
- Clues will be side-by side with grid if width permits,
  them will wrap to below grid as width reduces
- Change size units from 'em' to 'rem'
modified:   dev/index.html
- Create two major blocks in body
  '
modified:   dev/index.js
modified:   style/crosswords.less
new file:   style/cwcolors.less
new file:   style/cwdimensions.less

Addition of info from cw def using simple js.
chore: Introduce pug html template engine.
modified:   dev/index.html
modified:   dev/index.js
- Trial addition of information from crossword definition
  using only javascript and 'span' element injection via
  element id. Limited results as we can't populate anchor
  tag href strings using span elements.
  Switching to 'pug' html template engine. This will also
  affors us looping and condtionals in template code.
modified:   .eslintrc.yml
- Add vite config to 'import/no-extraneous-dependencies'
modified:   package-lock.json
modified:   package.json
- Add pug for html templates in 'dev'
new file:   vite.config.js
- Add pug to plugins
deleted:    nodemon.json
- No longer used since vite introduced

Adnd html template docs. jQuery no longer used.
new file:   docs/html-templates.md
- Add dcumentation for HTML tempalte engine pug.
deleted:    dev/vendor/jquery/jquery.js
deleted:    dev/vendor/jquery/jquery.min.js
deleted:    dev/vendor/jquery/jquery.min.map
modified:   package.json
- Remove jQuery

Add titel block template. Pug integration broken.
modified:   dev/index.html
modified:   dev/index.js
new file:   dev/template/title-block.pug
modified:   vite.config.js
 - Add code for JS injection into Pug templates.
   Not working. Time to read up on Vite config!

Pug import broken. Add Vite docs.
modified:   dev/index.html
- Move reset.css into dev folder
- Move title-block.pug into dev folder
renamed:    style/reset.css -> dev/reset.css
- Unreachable from dev/index.html when not under dev
renamed:    dev/template/title-block.pug -> dev/title-block.pug
- Add variable referencing
new file:   docs/vite.md
- Links to resources for Vite and vite-plugin-pug
modified:   package-lock.json
- version updates
modified:   vite.config.js
- Flattened 'locals'

Minor changes
modified:   src/crossword-controller.mjs
- Silence tracing from #newCEllElement
modified:   vite.config.js
- Load crossword via import statement

Trialing 'vite-plugin-pug-transformer'. Broken.
modified:   dev/index.html
- Change element for pug import
new file:   jsconfig.json
- TypeScript config file for a JS project as described here:
   https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
   Including TS may get things working?
modified:   package-lock.json
modified:   package.json
- Add 'vite-plugin-pug-transformer' and 'typescript'
modified:   src/crossword-controller.mjs
- Add sanity checks for 'CrosswordController' constructor args.
modified:   vite.config.js
 - Change to use hardcode strings for crossword info data in pug template
Add crossword clues DOM element. Working. Styling to come.
modified:   dev/index.html
- Disable title info template for now.
  Needs to be populated dynamically when crossword changes.
modified:   dev/index.js
- Add crosswordCluesParent assignment
modified:   src/crossword-controller.mjs
- Add #crosswordCluesView
- Rename #domParentElement -> #domGridParentElement
- Add method #newCrosswordCluesView
- Clues appearing.
- Click event handlers are firing.
modified:   style/crosswords.less
 - Changes to include crossword clues
 - Start styling for clue block

Working on layout. wip.
modified:   dev/index.css
- Add flex to groups. wip.
modified:   dev/index.html
- Added div 'groups' to wrap groups.
- Can be removed and styles moved up to body.
modified:   dev/index.js
- Adjust for changed element ids in dev/index.html
modified:   dev/reset.css
 - Formatted. nfc.
modified:   package.json
- Change prettier rules to process style files under dev
modified:   src/crossword-controller.mjs
- Add div 'title' to crossword clues view.
- title will span full-width, with clue gropus below
- Change some ids
modified:   style/crosswords.less
modified:   style/cwdimensions.less
- Move grid sizes into style/cwdimensions.less
modified:   style/cwcolors.less
- Harmonising 'current' element colours across grid and clues. wip.

More clues styling. wip.
modified:   dev/index.html
modified:   dev/index.js
- div id change
modified:   src/crossword-controller.mjs
- Remove title, add wrapper (for different flex of clue groups to block)
- Nasty hack to get clue text to align after clue label of varying
  width. Replace with separate elements for label and text,answer-length
modified:   style/crosswords.less
- Introduce flex wrap to clue groups so down wraps under across as
  display width shrinks

Behaving as three groups now.
modified:   dev/index.css
modified:   dev/index.html
- Outermost group (page-wrapper) is a row-oriented flexbox.
  It contains 3 columns:
  * first-column - column-oriented flexbox
    title-block
    crossword-grid-wrapper (grid parent element)
    current-clue
  * second-column - row-oriented flexbox with wrap and width min-content
    //TODO: Better as column-oriented flexbox?
    api-block
  * third-column - row-oriented flexbox with wrap
    crossword-clues - (clues parent element)
modified:   dev/index.js
- change ids of parent elements for grid and clues
modified:   src/crossword-controller.mjs
- simplify construction in #newCrosswordCluesView
modified:   style/crosswords.less
- crossword-clues-block renamed to crossword-clues-wrapper

Adjust layout
modified:   dev/index.css
modified:   dev/index.html
modified:   dev/index.js#
Break clue element into collection of three spans
modified:   src/crossword-controller.mjs
- Extract method addClueElements
  Break clue element into collection of three spans,
  so we can style each clue paret separately.

Clue text aligned
modified:   src/crossword-controller.mjs
- Combine clue text and answer length into one element
modified:   style/crosswords.less
- Fix reference to class 'crossword-clues'
- Style clue-label as display:inline-block to set overall label width
Handle clueSelected for controller.#crosswordCluesView
modified:   src/crossword-controller.mjs
modified:   style/crosswords.less
- Resolve multiple import problem (move to global scope)
- Add styling for selectec clues
modified:   style/cwdimensions.less
 - Reinstate dimemsion for clue label width

Clue view now responding correctly to current clue
changes in model.
modified:   dev/index.css
- Change body background colour
modified:   src/crossword-controller.mjs
- Add modelClue property to clueElement to allow
  comparison of current model clue to clue associated
  with view clue in onStateChanged handler
modified:   style/crosswords.less
- Add padding to clues
modified:   style/cwcolors.less
- Rationalise and rename colours so we have
  @cell-current-color and @clue-current-color rather than
  confusing adjectival colour names.
…sub, controller.addEventListener

Current clue element working in dev.
Todo: wrap currrent clue at grid width.
modified:   dev/index.css
- Tweak styling of #current-clue
modified:   dev/index.html
- Remove placeholder text for #current-clue
modified:   dev/index.js
- Hook up #current-clue to 'clueSelected' controller event
modified:   sample/sampleapp.js
- Change to use controller.addEventListener
modified:   src/crossword-controller.mjs
- Add enumeration controllerEvents
- Relocate initialisation of simple CrosswordController private
  members to declaration point
- Add pub-sub facilty to CrosswordController
- Wrap pub-sub as getter addEventListener
- Change implementation of #stateChange to use pub-sub
- #newCrosswordCluesView now uses pub-sub
modified:   src/helpers.mjs
- Add newPubSub implementation as a helper
modified:   style/crosswords.less
- Thin word separators to 1px
- Remove redundant import declarations
modified:   dev/crosswords/ftimes_17095.yml
 - Convert extended characters to UTF-8 equivalents
modified:   dev/index.css
- Add title-block padding
modified:   dev/index.html
- Move page heading out of title-block
- Add remaining info content to title-block
modified:   dev/index.js
- Group local functions at top of DOMContentLoaded
  event callback
- Extract eid() function
- Populate new title-block elements with json content
modified:   src/crossword-controller.mjs
- Simplify and remove redundant code for answer
  segment terminators
- Add missing clue argument to #stateChange call in
  focus event callback
modified:   style/crosswords.less
- Add styling for case of a cell being both an across
  and down word separator
modified:   dev/index.css
- Mirror styles for clues in styles/crosswords.less
modified:   dev/index.html
- Mirror structure of clues in CrossowrdCluesView for
  current clue element
modified:   dev/index.js
- rewrite logic for two span elements for current clue
modified:   src/crossword-controller.mjs
 - bugfix: typo caused unknown property - failing silently
   as undefined reference.
Fix README formatting.
modified:   README.md
modified:   dev/index.css

modified:   dev/index.html
    Changed API button text and added button group headings
modified:   dev/index.css
modified:   dev/index.html
modified:   style/cwcolors.less
deleted:    dev/index.css
new file:   dev/index.less
    Convert index styles to LESS format.
    Multiple styling changes - links, colours, hover behaviours.
modified:   dev/index.html
  Move reset.css to import in index.less.
  Move index style import to dev/index.js
  Change links to open in new browser tab.
  Add API block title element.
modified:   dev/index.js
  Import index styles here.
modified:   style/crosswords.less
modified:   style/cwcolors.less
modified:   style/cwdimensions.less
Add event crosswordCompleted and associated logic.
Multiple dev environment display tweaks.
Move reset.css into module source.
modified:   cspell.json
    Add tadah (src/crossword-controller.mjs)
modified:   dev/index.html
    Move title block inside first-column element.
modified:   dev/index.js
    Move all styling imports into index.js
    Reorder so local stlyes (dev/index.less) are applied last
    Add event listener for 'crosswordCompleted' event
modified:   dev/index.less
    Columns display horizontally-centred in page.
    Nest styles to match positioning in dev/index.html.
    This introduces unnecessary correlation between markup and styles,
    but I think is easier to grok and maintain.
    Remove redundant and ineffective styles. wip.
modified:   src/crossword-controller-helpers.mjs
    Modify testCell to conditionally show incorrect element
    - new showIncorrect argument - and skip if cell (answer) is empty.
    Correctly calculation of success for testClue.
modified:   src/crossword-controller.mjs
    Add controller event crosswordCompleted
    Controller constructor argument domCluesParentElement is now optional
    Add private controller method isCrosswordCompleted.
    Add public controller method testCrosswordCompletion.
    Add showIncorrect arguments to API testing calls.
    Modify testCrossword to return boolean.
    Add calls to testCrosswordCompletion for keypress event,
    revealCurrentCell, revealCurrentClue and revealCrossword.
    Add nested function newClueBlockElement inside newCrosswordCluesView
    to encapsulate clue block construction with nested block title
    element
    Add and modify some class names to simplify styling
    - prefix all styles with 'crossword-' to aviod namespace clashes.
modified:   style/crosswords.less
    Remove transition on .cwcell-revealed as this is blocked by
    crosswordCompleted event response. Remove opacity.
    Reducing styling in this file to element positioning and sizing
    and some default colors and fonts. wip.
modified:   style/cwcolors.less
modified:   style/cwdimensions.less
    Tweak some colors and 'revealed' cell glyph size.
renamed:    dev/reset.css -> style/reset.css
    Move reset.css into module source.

Add modal dialog for crossword completion
modified:   dev/index.html
    Add modal dialog elements for crossword completion
modified:   dev/index.js
    Add event handlers for crossword completion
modified:   dev/index.less
    Add styling for crossword completion
modified:   dev/index.html
    Initially hide HTML content to stop FOUC for slow link.
    Move stylesheet loading to end of markup.
    Move api-block-title out of api-block to isolate positioning.
    Change text for api-block-title abd cell-buttons label.
    Change '-wrapper' element suffixes to '-placeholder'.
modified:   dev/index.js
    Move stylesheet loading to markup to improve load time
    in older browsers.
    Change '-wrapper' element suffixes to '-placeholder'.
modified:   dev/index.less
    Nest styling dependencies - local changes ordered last.
    FOUC prevention bookend - reset html visibility.
    Move raw element styles ahead of positioning styles.
    Remove redundant/ineffective styles.
    Add media queries for responsive layout.
    Centre crossword-complete dialog in viewport in both directions.
    Change '-wrapper' element suffixes to '-placeholder'.
    Drop '-wrapper' suffix on root crossword-clues element for class
    name harmonisation with crossword-grid.
modified:   src/crossword-controller.mjs
    Test for crossword completion in testCrossword().
    Drop '-wrapper' suffix on root crossword-clues element for class
    name harmonisation with crossword-grid.
modified:   style/cwcolors.less
modified:   style/crosswords.less
    Introduce crossword grid color. Cascading value was page text color.
    Remove redundant styles.
    Drop '-wrapper' suffix on root crossword-clues element for class
    name harmonisation with crossword-grid.
modified:   style/cwdimensions.less
    Fixup units on @clue-text-width
Tweak the modal dialogue content

Ignore vite dev build artifacts

Add web font to dev

elementEventHandler method rename and documentation changes

Remove references to 'modal' dialogue

README tweaks. wip.
  modified:   README.md
  modified:   dev/index.html
  modified:   dev/index.js
Increase grid sizes by 50% to improve legibility
modified:   dev/index.less
    Set root font size in html (default of 16px)
modified:   style/crosswords.less
    Thicken word separators by 50%
modified:   style/cwdimensions.less
    Increase grid sizes by 50% to improve legibility
    Maintain revealed size

Add media queries for grid sizes
modified:   dev/index.less
    Removed crossword-clue-text from media query
    Add current-clue to media queries
modified:   style/crosswords.less
    Add media queries for grid sizes
modified:   style/cwdimensions.less
    Add groups of grid dimensions for mdeia query use
Restore cell label size for higher res.

Flash link text on selection

nfc
- commit text amendments
- metadata changes e.g. file access properties
deleted:    dev/crosswords/ftimes_17095.yml
deleted:    dev/crosswords/guardian_quiptic_89.json
deleted:    test/test-crosswords/alberich_4.json
deleted:    test/test-crosswords/ftimes_17095.json
deleted:    test/test-crosswords/quiptic89.json
renamed:    dev/crosswords/alberich_4.json -> data/alberich_4.json
renamed:    dev/crosswords/ftimes_17095.json -> data/ftimes_17095.json
new file:   data/ftimes_17095.yml
renamed:    src/data/quiptic89.json -> data/quiptic_89.json
    Relocate crossword definition files to 'data' folder
modified:   README.md
    Adjust references to crossword definition files.
modified:   cspell.json
modified:   dev/index.js
modified:   docs/controller-api.md
    Add TOC, section on adding event handlers
renamed:    docs/crossworddefinition.md -> docs/crossword-definition.md
renamed:    docs/crosswordobject.md -> docs/crossword-object.md
new file:   docs/crossword-styling.md
    Add doco for module styling
deleted:    docs/html-templates.md
    Remove pug artifact
modified:   docs/vite.md
modified:   package.json
    Add yml files to prettier
modified:   sample/sampleapp.js
modified:   src/clue-model.mjs
modified:   src/crossword-controller.mjs
    Add 'this' binding to controller 'bind*' methods
modified:   test/crossword-model.specs.mjs
    Adjust references to crossword definition files.
modified:   cspell.json
    Add exception
modified:   data/quiptic_89.json
    answer property renamed as solution
new file:   docs/README.md
    Contents file for docs directory
modified:   docs/controller-api.md
    Minor tweaks. nfc.
modified:   docs/crossword-definition.md
    Minor tweaks. nfc.
new file:   docs/crossword-model.md
    Add preliminary description of clue data structure.
    Expand cell description.
deleted:    docs/crossword-object.md
    crossword-object.md renamed as crossword-model.md
modified:   docs/crossword-styling.md
    Add more references - attribute reset.css
    Extract "Suggested configuration" section
modified:   src/clue-model.mjs
    Refactoring: extract helpers for newClueModel()
    to reduce complexity.
    Refactoring: use string.endsWith() where appropriate
modified:   src/crossword-model.mjs
    Refactoring: extract helpers for newCrosswordModel()
    to reduce complexity.
    Refactoring: use for..of loop where appropriate
modified:   test/crossword-model.specs.mjs
    Change terminology from 'non-linear' clue to 'multi-segment' clue
Add doc sections on grid and clue view elements.

modified:   dev/index.js
    Fix crossword location.
modified:   docs/README.md
    Re-order content and modify file descriptions
modified:   docs/crossword-definition.md
    Remove unclear references to segment ordering.
modified:   docs/crossword-model.md
    Fix bug in description of clueModel
modified:   docs/crossword-styling.md
    Rename 'Dev page' section as 'Crossword clues'
renamed:    docs/controller-api.md -> docs/module-api.md
    Reformat and changed section names.
    Add sections on grid and clue view elements.
    Add EventData column to controller events table.
    Add links to styling docs
modified:   src/clue-model.mjs
    Shorten args in for..of loops.
    Refactor directionFromClueLabel() as nested function
    in buildConnectedDirectedClues().
    Remove bug in description of clueModel.solution
modified:   src/crossword-controller.mjs
    Pass 'data' to listeners where absent.
    Refactor isCurrentClueSegment().
    Extract addEventListeners() helper for #newCellElement()
    Refactor logic in 'keydown' event listener to switch statement
modified:   src/crossword-model.mjs
    Extract helpers for newCrosswordModel()
modified:   sample/sampleapp.js
    Fix crossword location. Minor refactor.
modified:   README.md
    Add links to documentation pages.
    Minor content and format changes.
    Update TODOs with completed items
modified:   docs/keyboard-shortcuts.md
    Add default DELETE shortcut.
    Correct behaviour of BACKSPACE
    Minor content tweaks.
modified:   docs/module-api.md
    Fix type of CrosswordModel
modified:   README.md
modified:   docs/README.md
renamed:    docs/crossword-model.md -> docs/crossword-data-structures.md
    Renamed crossword-model.md -> crossword-data-structures.md
modified:   docs/module-api.md
    Prettier reformat
modified:   docs/crossword-definition.md
deleted:    sample/crosswords/alberich_4.json
deleted:    sample/crosswords/ftimes_17095.json
deleted:    sample/crosswords/guardian_quiptic_89.json
    Redirected crossword samples under sample/ to data/
@pvspain
Copy link
Contributor Author

pvspain commented Aug 10, 2023

Hi Dave,
If you'd rather deal with the PR locally in your own IDE rather than GitHub, I've written a gist with step by step instructions:

@dwmkerr
Copy link
Owner

dwmkerr commented Aug 15, 2023

Let's just get it in! Merge it all and fix forwards if needed?

@dwmkerr
Copy link
Owner

dwmkerr commented Aug 15, 2023

Thanks for all of this!

@pvspain
Copy link
Contributor Author

pvspain commented Aug 24, 2023

Hi Dave,

I'm happy to merge in the PR #34 changes, but I don't have write access to the repo. I've merged the changes to a local version but can't push to the remote.

You've made me a contributor but not a collaborator methinks - I can't see the Settings menu.

https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-access-to-your-personal-repositories/inviting-collaborators-to-a-personal-repository#inviting-a-collaborator-to-a-personal-repository

Cheers, Paul

@mmkal
Copy link
Contributor

mmkal commented Aug 25, 2023

Hi @pvspain and @dwmkerr, just a note on this. I tried it out by installing c074f80 as an npm module via github, something like this in package.json

"dependencies": {
  "crosswords-js": "github:pvspain/crosswords-js#c074f80024ee162c1f811ec9c30740024420a435"
}

I was able to get it to work but only after also installing less, and running lessc node_modules/crosswords-js/style/crosswords.less src/styles/crosswords-js-compiled.css and then using that compiled css file instead of the shipped one, which didn't seem to style things correctly.

I'm also doing import { CrosswordsJS } from 'crosswords-js/src/index.mjs' rather than using the dist folder, so that may be why. But it does seem that dist/crosswords.css is out of date, and since it's checked in, that should probably be addressed. I didn't start digging into the webpack config to see if something should be changed to make it spit out the right css, because npm install less worked first time.

@mmkal
Copy link
Contributor

mmkal commented Aug 25, 2023

Also, I've started writing some typescript declarations for the core methods, please let me know if you'd be interested in a pull request adding them to the main repo.

@pvspain
Copy link
Contributor Author

pvspain commented Aug 26, 2023

Hi @mmkal, we're merging a lot of changes and there's a bit of a disconnect in the main branch. I don't think the angular sample has been working for some time. We're using Vite for bundling in the incoming code for the sample in dev and Webpack continues in the main branch. Less has been added to the package in the incoming code, and the Vite prod artifacts are currently appearing in dev/dist on running npm run dev:build in the incoming branch.

The typescript wrapper would be great. I'd hold off for now till the merge is complete.

Thanks for your patience and interest!

@pvspain
Copy link
Contributor Author

pvspain commented Aug 26, 2023 via email

@pvspain pvspain closed this Aug 29, 2023
@pvspain
Copy link
Contributor Author

pvspain commented Aug 29, 2023

Changes moved to pvspain/main and new pull request issued from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants