beeware / beeware/toga

Provide a palette of system colors

Open
#2,843 0 comments 3 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### What is the problem or limitation you are having?

Toga's style engine has a (largely undocumented) concept of `SYSTEM_FONT_SIZE` - the default font size for text on the platform. It should also expose a selection of system *colors* that can be used.

### Describe the solution you'd like

Most platforms have a palette of "standard" colors - primary, secondary (, tertiary...) text color, hyperlink color, border color etc. Toga should determine a reasonable subset of "common" system colors, expose those as constants through Pack, and modify color handling so that if a "system" color is requested, a platform appropriate color is used.

This likely means defining constants like `toga.colors.SYSTEM_PRIMARY_TEXT` that can be mapped to platform-specific shades.

Interestingly, [CSS has a specification for this](https://drafts.csswg.org/css-color/#css-system-colors) - but they've been deprecated. This seems to be because in the HTML context, the potential for HTML pages to spoof actual system dialogs etc is dangerous - but in our case, that's what we're *trying* to do. It might make sense to use these constants (or a subset of them), even though they've been formally deprecated from the standard.

### Describe alternatives you've considered

Status quo - the system colors will be *used* if there's no explicit color provided, but it doesn't provide any way to use those colors in a different context.

### Additional context

See #2830 for the original request.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing issue #2830, the existing SYSTEM_FONT_SIZE handling, Pack, and toga.colors. Compare the proposed subset with the CSS system-colors specification and inspect platform color handling. Done means an agreed set of system-color constants is exposed and resolves to appropriate platform colors when requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.