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

Hotfix wrong override when value is not defined in breakpoint #6969

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,6 @@ exports[`Tip themed 1`] = `
animation-delay: 0.01s;
}

@media only screen and (max-width:768px) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to understand why this margin goes away with these changes. Can you explain?

.c0 {
margin: 21px;
}
}

@media only screen and (max-width:768px) {
.c2 {
margin: 3px;
Expand Down
12 changes: 7 additions & 5 deletions src/js/utils/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ export const edgeStyle = (
responsiveBreakpoint,
theme,
) => {
const breakpoint =
responsiveBreakpoint && theme.global.breakpoints[responsiveBreakpoint];
const breakpoint = getBreakpointStyle(theme, responsiveBreakpoint);
const metric = theme.global.edgeSize[data] || data;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior looks great. Two small naming suggestions would be to align the variable names with the concept of CSS value. Metric was a little bit confusing at first:

  • metric --> value
  • responsiveMetric --> responsiveValue

soft opinion.

const responsiveMetric = responsive && breakpoint &&
breakpoint.edgeSize[data];

if (typeof data === 'string') {
return css`
${kind}: ${theme.global.edgeSize[data] || data};
${responsive && breakpoint
${kind}: ${metric};
${responsiveMetric
? breakpointStyle(
breakpoint,
`
${kind}: ${breakpoint.edgeSize[data] || data};
${kind}: ${responsiveMetric};
`,
)
: ''};
Expand Down