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

legacyLogicalPropertiesTransformer 没有正确拼接 calc() #96

Open
Airkro opened this issue Mar 7, 2023 · 2 comments
Open

legacyLogicalPropertiesTransformer 没有正确拼接 calc() #96

Airkro opened this issue Mar 7, 2023 · 2 comments

Comments

@Airkro
Copy link

Airkro commented Mar 7, 2023

calc(a + b) 的拼接缺少必要的空格。

Sider 内的折叠 Menu Icon 受到明显的影响,无法居中对齐:

image
image

相关问题:

@Airkro
Copy link
Author

Airkro commented Mar 8, 2023

临时解决方案:

const transformers = [
  legacyLogicalPropertiesTransformer,
  {
    visit(cssObj) {
      for (const item of Object.values(cssObj)) {
        if (typeof item.value === 'string' && item.value === 'calc(50%-14px)') {
          item.value = item.value.split('-').join(' - ');
        }
      }
    },
  },
];

@susususutie
Copy link

susususutie commented Apr 11, 2023

临时解决方案:

const transformers = [
  legacyLogicalPropertiesTransformer,
  {
    visit(cssObj) {
      for (const item of Object.values(cssObj)) {
        if (typeof item.value === 'string' && item.value === 'calc(50%-14px)') {
          item.value = item.value.split('-').join(' - ');
        }
      }
    },
  },
];

这里14px是不固定的, 我改成用正则了

if (
  item &&
  typeof item === 'object' &&
  value' in item &&
  typeof item.value === 'string' &&
 /calc\(50%-\d+px\)/.test(item.value)
) {
   item.value = item.value.split('-').join(' - ');
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants