Skip to content

Commit

Permalink
Allow string values for 'padding' and 'margin' properties
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmk committed Dec 26, 2023
1 parent db52db7 commit 361f1c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
20 changes: 8 additions & 12 deletions ext/data/schemas/dictionary-term-bank-v3-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,40 +332,36 @@
"default": "unset"
},
"marginTop": {
"type": "number",
"type": ["number", "string"],
"default": 0
},
"marginLeft": {
"type": "number",
"type": ["number", "string"],
"default": 0
},
"marginRight": {
"type": "number",
"type": ["number", "string"],
"default": 0
},
"marginBottom": {
"type": "number",
"type": ["number", "string"],
"default": 0
},
"padding": {
"type": "string",
"default": "unset"
},
"paddingTop": {
"type": "number",
"default": 0
"type": "string"
},
"paddingLeft": {
"type": "number",
"default": 0
"type": "string"
},
"paddingRight": {
"type": "number",
"default": 0
"type": "string"
},
"paddingBottom": {
"type": "number",
"default": 0
"type": "string"
},
"wordBreak": {
"type": "string",
Expand Down
12 changes: 8 additions & 4 deletions ext/js/display/sandbox/structured-content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,18 @@ export class StructuredContentGenerator {
if (typeof borderWidth === 'string') { style.borderWidth = borderWidth; }
if (typeof margin === 'string') { style.margin = margin; }
if (typeof marginTop === 'number') { style.marginTop = `${marginTop}em`; }
if (typeof marginTop === 'string') { style.marginTop = marginTop; }
if (typeof marginLeft === 'number') { style.marginLeft = `${marginLeft}em`; }
if (typeof marginLeft === 'string') { style.marginLeft = marginLeft; }
if (typeof marginRight === 'number') { style.marginRight = `${marginRight}em`; }
if (typeof marginRight === 'string') { style.marginRight = marginRight; }
if (typeof marginBottom === 'number') { style.marginBottom = `${marginBottom}em`; }
if (typeof marginBottom === 'string') { style.marginBottom = marginBottom; }
if (typeof padding === 'string') { style.padding = padding; }
if (typeof paddingTop === 'number') { style.paddingTop = `${paddingTop}em`; }
if (typeof paddingLeft === 'number') { style.paddingLeft = `${paddingLeft}em`; }
if (typeof paddingRight === 'number') { style.paddingRight = `${paddingRight}em`; }
if (typeof paddingBottom === 'number') { style.paddingBottom = `${paddingBottom}em`; }
if (typeof paddingTop === 'string') { style.paddingTop = paddingTop; }
if (typeof paddingLeft === 'string') { style.paddingLeft = paddingLeft; }
if (typeof paddingRight === 'string') { style.paddingRight = paddingRight; }
if (typeof paddingBottom === 'string') { style.paddingBottom = paddingBottom; }
if (typeof wordBreak === 'string') { style.wordBreak = wordBreak; }
if (typeof whiteSpace === 'string') { style.whiteSpace = whiteSpace; }
if (typeof cursor === 'string') { style.cursor = cursor; }
Expand Down
10 changes: 5 additions & 5 deletions test/data/dictionaries/valid-dictionary1/term_bank_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
"style": {
"fontSize": "0.7em",
"fontWeight": "bold",
"paddingTop": 0.15,
"paddingRight": 0.3,
"paddingBottom": 0.3,
"paddingLeft": 0.3,
"paddingTop": "0.15em",
"paddingRight": "0.3em",
"paddingBottom": "0.3em",
"paddingLeft": "0.3em",
"wordBreak": "keep-all",
"borderRadius": "0.3em",
"verticalAlign": "text-bottom",
"backgroundColor": "brown",
"color": "white",
"cursor": "help",
"marginRight": 0.25
"marginRight": "0.25em"
},
"data": {
"code": "uk"
Expand Down
16 changes: 8 additions & 8 deletions types/ext/structured-content.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ export type StructuredContentStyle = {
verticalAlign?: VerticalAlign;
textAlign?: TextAlign;
margin?: string;
marginTop?: number;
marginLeft?: number;
marginRight?: number;
marginBottom?: number;
marginTop?: number | string;
marginLeft?: number | string;
marginRight?: number | string;
marginBottom?: number | string;
padding?: string;
paddingTop?: number;
paddingLeft?: number;
paddingRight?: number;
paddingBottom?: number;
paddingTop?: string;
paddingLeft?: string;
paddingRight?: string;
paddingBottom?: string;
wordBreak?: WordBreak;
whiteSpace?: string;
cursor?: string;
Expand Down

0 comments on commit 361f1c4

Please sign in to comment.