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

feat: 自定义样式支持添加前缀;优化实现方式 #6934

Merged
merged 4 commits into from
May 22, 2023

Conversation

qkiroc
Copy link
Collaborator

@qkiroc qkiroc commented May 19, 2023

What

🤖 Generated by Copilot at e52b705

This pull request introduces a new CustomStyle component in amis-core that can insert custom CSS styles for AMIS components based on props. It also refactors several renderers in amis and amis-editor to use this component instead of injecting styles manually. Additionally, it adds a new customStyleClassPrefix property to the RendererEnv interface that can be used to customize the prefix of the generated CSS classes for custom styles.

🤖 Generated by Copilot at e52b705

Sing, O Muse, of the skillful work of the code smiths
Who crafted the CustomStyle component, a wondrous tool
To adorn the AMIS components with graceful themes and hues
Like Hephaestus, who forged the armor of the gods and heroes

Why

How

🤖 Generated by Copilot at e52b705

  • Add a new component CustomStyle that can insert custom CSS styles based on the themeCss and classNames props (link)
  • Import and export the CustomStyle component in the amis-core index file (link, link)
  • Add a new optional property customStyleClassPrefix to the RendererEnv interface, which can be used to customize the prefix of the generated CSS classes for custom styles (link)
  • Add optional chaining to the weights object in the formatStyle function, to prevent errors when the object is undefined or null (link)
  • Define a new interface CustomStyleClassName that represents the shape of the classNames prop for the CustomStyle component, and add a new parameter customStyleClassPrefix to the insertCustomStyle function, which can be used to prepend a custom prefix to the generated CSS classes (link)
  • Add a condition to prepend the customStyleClassPrefix to the value variable in the insertCustomStyle function, if the prefix is defined (link)
  • Replace the calls to insertCustomStyle with the CustomStyle component in the Action, InputImage, InputNumber, InputText, and Icon renderers, and pass the env prop from the parent component (link, link, link, link, link, link, link, link)
  • Add the env prop to the InputNumber and InputText components, which can be used to pass the custom style class prefix to the CustomStyle component (link, link)
  • Update the schema template names for the IconPlugin component, to match the new prop name for the custom style (link)
  • Remove the calls to insertCustomStyle for the label and description classes in the FormItemWrap component, and replace them with the CustomStyle component (link, link)

@github-actions github-actions bot added the feat label May 19, 2023
@github-actions
Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

@qkiroc qkiroc merged commit 1d0345d into baidu:master May 22, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants