Skip to content

style set through options and through theme sometimes clash for priority #12

@Shenato

Description

@Shenato

The developer's own custom entry in either theme or in options should override the default values.

If the developer has passed both a theme and an option for any style prop then the the option takes priority.

Example is #6

The current code in round-headers.tsx looks like this

const Rect = styled.rect.attrs(({ theme }) => ({
  fill: theme.roundHeaders.background,
}))``;
...

  <Rect
    x={x}
    y={y + canvasPadding}
    width={width}
    height={roundHeader.height}
    fill={roundHeader.backgroundColor}
    rx="3"
    ry="3"
  />

Which makes it so the theme always wins even if it's the default theme against the user set value in options for roundHeaders.backgroundColor

It should be something this but more abstracted for all other values as well to centralize the logic

const Rect = styled.rect.attrs(({ theme, fill }) => ({
  fill:
    fill !== defaultStyle.roundHeader?.backgroundColor
      ? fill
      : theme.roundHeaders.background,
}))``;
...

  <Rect
    x={x}
    y={y + canvasPadding}
    width={width}
    height={roundHeader.height}
    fill={roundHeader.backgroundColor}
    rx="3"
    ry="3"
  />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions