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

CSS styling of text inside boxes #73

Open
mbrannstrom opened this issue Jun 7, 2021 · 3 comments
Open

CSS styling of text inside boxes #73

mbrannstrom opened this issue Jun 7, 2021 · 3 comments

Comments

@mbrannstrom
Copy link

mbrannstrom commented Jun 7, 2021

I love the new CSS styling feature. It would be great if it was possible to apply styling to text inside boxes (or other shapes).

In the following example, it would be nice to set the text color to e.g. white. (the filter works best in chrome)

+---------+
| Box {a} |
+---------+

# Legend:
a = {
  fill: darkred;
  filter: drop-shadow( 3px 3px 2px rgba(0, 0, 0, .7));
}

E.g. with the syntax:

a:text = { fill: white; }

Or, perhaps even better, make the entire styling block into pure CSS:

# CSS:
.a { fill: darkred; filter: drop-shadow( 3px 3px 2px rgba(0, 0, 0, .7)); }
text.a { fill: white; filter: none; }
text { /* styling of any other text */ }

The <text> element would thus have the class="a" applied, if it is inside a box with that class.

See the current output below:

Skärmavbild 2021-06-07 kl  13 43 05

@mdg-utility
Copy link

mdg-utility commented Nov 2, 2022

I'd like to add, that if all text had a text class, we'd be able to set default styles. Piggy backing on this issue request, if the text is within an object, you could add a class called text_object_name in addition to the default text class.

So by default, it would look like so:
<text x="42" y="3628" class="text">Statistical</text>

Then, using the example from @mbrannstrom above, the text element would look like so:
<text x="18" y="7100" class="text text_a">Box</text>

The legend would look like:

# Legend:
a = {
  fill: darkred;
  filter: drop-shadow( 3px 3px 2px rgba(0, 0, 0, .7));
}
text_a = {
  fill: white;
}

You could use the same/similar logic that you use to add the shape classes to the text elements within the shape.

If I wanted to style all text in the graphic, I'd use the following:

# Legend:
text = {
  fill: crimson;
}

@avivace
Copy link

avivace commented Feb 26, 2023

Agree, this unfortunately breaks every rendered SVG on dark themes :/

@mdg-utility
Copy link

It just gives the capability to style rendered SVGs. It would be up to the user to add the appropriate CSS, but adding the class itself shouldn't break anything.

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

No branches or pull requests

4 participants