Skip to content

Commit

Permalink
Add #setInlineStyleTo: to canvas brushes
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed May 22, 2018
1 parent 6567234 commit 08ceb48
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Class {
#name : #CssDeclarationBlockInSeasideTest,
#superclass : #TestCase,
#category : #'RenoirSt-Seaside-Tests'
}

{ #category : #Tests }
CssDeclarationBlockInSeasideTest >> testGreaseStringOnDeclarationBlock [

| declarationBlock |
declarationBlock := CssDeclarationBlock new
margin: 2 px;
border: 1 cm;
yourself.

self assert: declarationBlock greaseString equals: 'margin: 2px;border: 1cm;'
]

{ #category : #Tests }
CssDeclarationBlockInSeasideTest >> testInlineStyleRendering [

| builder |

builder := WAHtmlCanvas builder
fullDocument: false;
yourself.

self
assert: (builder render: [ :html | html div setInlineStyleTo: [ :style | style margin: 1 px ] ])
equals: '<div style="margin: 1px;"></div>';
assert:
(builder
render: [ :html |
html div
setInlineStyleTo: [ :style :constants |
style
margin: constants >> #auto;
color: constants >> #colors >> #blue ] ])
equals: '<div style="margin: auto;color: blue;"></div>'
]

{ #category : #Tests }
CssDeclarationBlockInSeasideTest >> testJavascriptOnDeclarationBlock [

| declarationBlock |
declarationBlock := CssDeclarationBlock new
margin: 2 px;
border: 1 cm;
yourself.

self
assert: (String streamContents: [ :stream | declarationBlock javascriptOn: stream ])
equals: '{"margin":"2px","border":"1cm"}'
]

This file was deleted.

11 changes: 11 additions & 0 deletions source/RenoirSt-Seaside/WATagBrush.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : #WATagBrush }

{ #category : #'*RenoirSt-Seaside' }
WATagBrush >> setInlineStyleTo: aDeclarationAction [

| declarationBlock |

declarationBlock := CssDeclarationBlock new.
aDeclarationAction cull: declarationBlock cull: RenoirSt constants.
self style: declarationBlock
]
8 changes: 7 additions & 1 deletion source/RenoirSt/RenoirSt.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Class {
#category : #'RenoirSt-Common'
}

{ #category : #accessing }
RenoirSt class >> constants [

^ CssConstants
]

{ #category : #initialization }
RenoirSt class >> initialize [

Expand Down Expand Up @@ -619,5 +625,5 @@ RenoirSt class >> initializeUnits [
{ #category : #accessing }
RenoirSt class >> units [

^ CssConstants >> #units
^ self constants >> #units
]

0 comments on commit 08ceb48

Please sign in to comment.