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

Use CSS to define styling #346

Merged
merged 16 commits into from Jun 9, 2020
Merged

Use CSS to define styling #346

merged 16 commits into from Jun 9, 2020

Conversation

amolenaar
Copy link
Member

This PR is a continuation of #320.

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation content changes

What is the current behavior?

Styling can be defined, but as a Python dict in the config folder.

Issue Number: #284

What is the new behavior?

Styling can be defined in CSS syntax. This PR handles the processing of a CSS file and allows the CSS style to be applicable for elements.

I want to limit the scope to the * CSS selector.

Out of scope: CSS selectors.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@amolenaar amolenaar marked this pull request as draft June 4, 2020 20:38
@amolenaar amolenaar modified the milestone: 2.0 Jun 4, 2020
@amolenaar amolenaar self-assigned this Jun 4, 2020
@amolenaar amolenaar added the feature A new feature label Jun 4, 2020
@amolenaar
Copy link
Member Author

CSS is read:

image

The style sheet is added to the model, so if you open example/all-elements.gaphor, you should see the model as above, with alternate color and font.

@amolenaar amolenaar requested a review from danyeaw June 7, 2020 14:58
@amolenaar amolenaar marked this pull request as ready for review June 7, 2020 14:59
@amolenaar
Copy link
Member Author

Now in the Console, you can change the stylesheet like this:

Gaphor Interactive Python Console
3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0]
Type "help" for more information.
>>> from gaphor import UML
>>> ef = service("element_factory")
>>> s = ef.lselect(UML.StyleSheet)[0]
>>> s.styleSheet = "* {background-color: rgba(255, 143, 65, 0.2); }"
>>> s._style
{'background-color': (1.0, 0.5607843137254902, 0.2549019607843137, 0.2)}
>>> s.styleSheet = "* {background-color: rgba(255, 143, 200, 0.2); }"
>>> 

@amolenaar amolenaar mentioned this pull request Jun 7, 2020
12 tasks
@danyeaw danyeaw merged commit 44c51b2 into master Jun 9, 2020
@danyeaw danyeaw deleted the css-styling branch June 9, 2020 02:21
@danyeaw danyeaw added this to the 2.0 milestone Jun 9, 2020
@danyeaw
Copy link
Member

danyeaw commented Jun 9, 2020

Excellent! 🎉

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

Successfully merging this pull request may close these issues.

None yet

2 participants