-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
refactor: migrate helpers.options to typescript #10753
Conversation
src/helpers/helpers.options.ts
Outdated
@@ -120,7 +126,7 @@ export function toFont(options, fallback) { | |||
let style = valueOrDefault(options.style, fallback.style); | |||
if (style && !('' + style).match(FONT_STYLE)) { | |||
console.warn('Invalid font style specified: "' + style + '"'); | |||
style = ''; | |||
style = 'inherit'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure about this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to restore it, or try undefined
style = 'inherit'; | |
style = undefined; |
maybe this will fix tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty string wont work, tried undefined
but ubuntu test is still broken
@etimberg another one |
cbe29c6
to
a8f5642
Compare
46ea8ec
to
568749c
Compare
src/helpers/helpers.options.ts
Outdated
const obj: ChartArea = { | ||
...toTRBL(value), | ||
width: 0, | ||
height: 0, | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem is here
const obj: ChartArea = { | |
...toTRBL(value), | |
width: 0, | |
height: 0, | |
top: 0, | |
left: 0, | |
right: 0, | |
bottom: 0 | |
}; | |
const obj: ChartArea = { | |
...toTRBL(value), | |
width: 0, | |
height: 0 | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! 🎉
src/helpers/helpers.options.ts
Outdated
const LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); | ||
const FONT_STYLE = new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
const LINE_HEIGHT = new RegExp(/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/); | |
const FONT_STYLE = new RegExp(/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/); | |
const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/; | |
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple of nits
@luckened for the nits do you want to address them in this PR or a followup? |
src/helpers/helpers.options.ts
Outdated
} | ||
|
||
return size * value; | ||
} | ||
|
||
const numberOrZero = v => +v || 0; | ||
const numberOrZero = (v: number) => +v || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const numberOrZero = (v: number) => +v || 0; | |
const numberOrZero = (v: unknown) => +v || 0; |
src/helpers/helpers.options.ts
Outdated
export function toPadding(value) { | ||
const obj = toTRBL(value); | ||
export function toPadding(value?: number | TRBL): ChartArea { | ||
const obj: ChartArea = {...toTRBL(value), width: 0, height: 0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const obj: ChartArea = {...toTRBL(value), width: 0, height: 0}; | |
const obj = toTRBL(value) as ChartArea; |
a5e1d42
@etimberg commited the nits, better to do them right away |
Refactor
src/helpers/helpers.options.js
to typescript and apply required changes