Skip to content

Commit

Permalink
Set the word with query parameter (for testing purposes)
Browse files Browse the repository at this point in the history
  • Loading branch information
tatut committed Jan 13, 2024
1 parent 2592e15 commit 6a0555d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/LiveWeb-Examples/LWExampleMain.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LWExampleMain >> renderOn: h [

{ #category : #accessing }
LWExampleMain >> state: aDictionary [
| ex |
| ex component |
state := aDictionary.

"check push state for example to use"
Expand All @@ -50,8 +50,12 @@ LWExampleMain >> state: aDictionary [
'crud' -> LWCrudExample.
'typeahead' -> LWTypeAheadExample.
'tree' -> LWTreeExample } asDictionary at: (state at: 'example').

"set the child component to a new instance and change active item for menu"
example child: ex new.
"create new instance of example component"
component := ex new.
ex = LWWordle ifTrue: [ component configure: (state at: 'query') ]. "for tests"

"set the child component to the example instance"
example child: component.

menu active: (state at: 'example').
]
2 changes: 1 addition & 1 deletion src/LiveWeb-Examples/LWExamplePage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LWExamplePage >> initialPushState [
| example |
example := args uri segments last.
LWLogEvent debug: 'we got the args: ', example asString.
^ { #example -> example } asDictionary
^ { #example -> example. #query -> args uri query } asDictionary
]

{ #category : #'as yet unclassified' }
Expand Down
7 changes: 7 additions & 0 deletions src/LiveWeb-Examples/LWWordle.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ LWWordle >> children [
]
]

{ #category : #configuring }
LWWordle >> configure: queryParams [
(queryParams includesKey: 'cheat') ifFalse: [ ^ self ].
word := queryParams at: 'cheat'.
guesses do: [ :g | g word: word ]
]

{ #category : #'instance creation' }
LWWordle >> enter [
"enter the current guess"
Expand Down
7 changes: 5 additions & 2 deletions src/LiveWeb-Examples/LWWordleGuess.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ LWWordleGuess >> renderOn: h [
h div: { self style wordleGuess }
with: [
1 to: 5 do: [ :i |
| ch inWord inPosition |
| ch inWord inPosition cls |
ch := guess at: i ifAbsent: Character space.
inWord := committed & (word includes: ch).
inPosition := committed & ((word at: i) = ch).
h div: { self style wordleGuessCharacter: inPosition word: inWord }
cls := String streamContents: [ :c |
inPosition ifTrue: [ c nextPutAll: 'in-position ' ].
inWord ifTrue: [ c nextPutAll: 'in-word' ] ].
h div: { (self style wordleGuessCharacter: inPosition word: inWord), (#class -> cls) }
with: ch.
]
]
Expand Down

0 comments on commit 6a0555d

Please sign in to comment.