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

Fixes component info font size #9651

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fixes component info font size #9651

wants to merge 2 commits into from

Conversation

dawoodkhan82
Copy link
Collaborator

@dawoodkhan82 dawoodkhan82 commented Oct 10, 2024

Description

  • Fixes css applied to markdown in info.
Screenshot 2024-10-10 at 11 55 23 AM

Closes: #9642

🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is an existing issue for this change. If not, please create an issue before you create this PR, unless the fix is very small.

Not adhering to this guideline will result in the PR being closed.

Tests

  1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up your Gradio environment locally and run the tests: bash scripts/run_all_tests.sh

  2. You may need to run the linters: bash scripts/format_backend.sh and bash scripts/format_frontend.sh

@gradio-pr-bot
Copy link
Collaborator

gradio-pr-bot commented Oct 10, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Storybook ready! Storybook preview
🦄 Changes detected! Details

Install Gradio from this PR

pip install https://gradio-pypi-previews.s3.amazonaws.com/1165c105f2ab7d768dd6d7f637772f9fdae67840/gradio-5.0.1-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@1165c105f2ab7d768dd6d7f637772f9fdae67840#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-npm-previews.s3.amazonaws.com/1165c105f2ab7d768dd6d7f637772f9fdae67840/gradio-client-1.6.0.tgz

Use Lite from this PR

<script type="module" src="https://gradio-lite-previews.s3.amazonaws.com/1165c105f2ab7d768dd6d7f637772f9fdae67840/dist/lite.js""></script>

@gradio-pr-bot
Copy link
Collaborator

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/atoms patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fixes component info font size

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Comment on lines +12 to 17
:global(.md) {
margin-bottom: var(--spacing-lg);
color: var(--block-info-text-color);
font-weight: var(--block-info-text-weight);
font-size: var(--block-info-text-size);
font-weight: var(--block-info-text-weight) !important;
font-size: var(--block-info-text-size) !important;
line-height: var(--line-sm);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that its not good practice to use the !important here. It would be better to pass in an optional parameter into Markdown that adjusts the font size to be smaller

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah probably not, but the actual font size that I'm overriding is not in the Markdown component but even lower in the stack in the Embed component. Font size would have to be passed a few time I think, which is probably messy. We use !important is a bunch of other places too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid introducing !important when easily possible, its a bad practice.

@abidlabs
Copy link
Member

Font size looks good @dawoodkhan82 but previously, we would also use a subdued color for the info text. Compare 4 (top) vs. 5 (bottom), which would be nice to bring back:

image image

I also think there should be slightly more padding underneath the info text

@@ -9,11 +9,11 @@
</div>

<style>
div {
:global(.md) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:global is very dangerous and should be avoided when not scoped, this will affect all classes with md. You can scope it to be div > :global(.md) so it only targets the md inside div.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lemme take a look at the issue and see if there's a better solution

@aliabid94
Copy link
Collaborator

Use this instead:

	div > :global(.md.prose) {
		color: var(--block-info-text-color);
		font-weight: var(--block-info-text-weight);
		font-size: var(--block-info-text-size);
		line-height: var(--line-sm);
	}
	div {
		margin-bottom: var(--spacing-md);
	}

Avoids the use of !important, scopes the :global, and the margin bottom wasn't being applied to a span since it's display: inline, so apply it to the div.

@aliabid94
Copy link
Collaborator

Honestly passing in the style configuration as parameters to the Markdown svelte component is also a fine approach, and is less likely to break in case we change class names in Markdown.svelte.

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

Successfully merging this pull request may close these issues.

Component info font size not smaller in v5
4 participants