Skip to content

[Help] Conflict with MUI in Storybook #14

@marc-gavanier

Description

@marc-gavanier

Standard preview of badge component shows like this:
image

But when I apply isSmall property

image

The preview renders with a text size issue:

image

After looking in navigator inspector, I noticed that .fr-badge--sm has been overriden

fr-badge--sm {
  font-size: 0.75rem; /* overriden */
  line-height: 1.25rem; /* overriden */
  min-height: 1.125rem;
  padding: 0 0.375rem;
  overflow: initial;
  max-width: 100%;
  max-height: none;
}

It appears that p:not([class^="Mui"]) is responsible of this behaviour:

p:not([class^="Mui"]) {
  font-size: 1rem;
  line-height: 1.5rem;
  margin: var(--text-spacing);
}

Preview is OK after disabling font-size and line-height styles:
image

After looking in project files, p:not([class^="Mui"]) selector is present in dsfr/dsfr(.min).css files which are generated while running yarn build command.

This code in patchCssForMui.ts is probably the root of the problem:

const selectorNotMui = `${selector}:not([class^="Mui"])`;

if (media === "root") {
    if (selector === "[href]") {
        return selectorNotMui;
    }

    if (selector === "p") {
        return selectorNotMui;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions