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

[cssVariables] Creating variables for typography with responsive incorrectly and not work #44294

Open
mtr1990 opened this issue Nov 2, 2024 · 4 comments
Assignees
Labels
component: Typography The React component. customization: theme Centered around the theming features new feature New feature or request

Comments

@mtr1990
Copy link

mtr1990 commented Nov 2, 2024

Steps to reproduce

When create theme with typography with h1 include responsive:

const theme = createTheme({
...
  typography: {
    fontFamily: roboto.style.fontFamily,
    h1: {
      fontSize: '2.8rem',
      color: 'red',
      fontWeight: 'bold',
      '@media (min-width:300px)': {
        fontSize: '3rem',
      },
      '@media (min-width:400px)': {
        fontSize: '4rem',
      },
    },
  ...
  },
...
  },
});

Current behavior

This variable appears to be non-existent or malformed

// output:
  '@media (min-width:400px)': {
    fontSize: var(--typography-h1-@media (min-width:400px)-fontSize)
  },

https://stackblitz.com/edit/github-emurbz?file=src%2Ftheme.ts,src%2Fapp%2Fpage.tsx,src%2Fcomponents%2FProTip.tsx,src%2Fcomponents%2FCopyright.tsx

kk

xx

Expected behavior

Generate variables that match media keys (300px, 400px...) and accept these values.

Context

No response

Your environment

No response

Search keywords: cssVariables typography responsive

@mtr1990 mtr1990 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 2, 2024
@mtr1990 mtr1990 changed the title cssVariables creating variables for typography with responsive incorrectly [cssVariables] Creating variables for typography with responsive incorrectly Nov 2, 2024
@mtr1990 mtr1990 changed the title [cssVariables] Creating variables for typography with responsive incorrectly [cssVariables] Creating variables for typography with responsive incorrectly and not work Nov 2, 2024
@zannager zannager added the component: Typography The React component. label Nov 4, 2024
@mtr1990
Copy link
Author

mtr1990 commented Nov 7, 2024

The current default theme mixins.toolbar also has this problem.

Variable generator seems misleading when working with @media.

I think this case is like: #44212

@siriwatknp
Copy link
Member

@mtr1990 What's the reason behind the custom shouldSkipGeneratingVar? It's not intended to be customized, at least we don't have a documentation of it yet.

@siriwatknp siriwatknp added status: waiting for author Issue with insufficient information customization: theme Centered around the theming features and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 12, 2024
@mtr1990
Copy link
Author

mtr1990 commented Nov 12, 2024

@mtr1990 What's the reason behind the custom shouldSkipGeneratingVar? It's not intended to be customized, at least we don't have a documentation of it yet.

I only see typography variables created whenshouldSkipGeneratingVar is used. So if not usingshouldSkipGeneratingVar option how to access typography with theme.vars.typography?

Because I also want to use these variables for .css files not .js like var(--typography-h1)

So css files do not accept syntax like theme.typography.h1. I see the --font-h1 variable is created by default. But it doesn't apply to responsive.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 12, 2024
@siriwatknp siriwatknp added new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 13, 2024
@siriwatknp
Copy link
Member

siriwatknp commented Nov 13, 2024

The current CSS theme variables don't support responsive typography yet. Mark this issue as a new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Typography The React component. customization: theme Centered around the theming features new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants