figma-plugin-color-system-utilities's People
figma-plugin-color-system-utilities's Issues
Define `ScaleNode` and `Scale`
ScaleNode
- Has a name following this RegExp pattern after trimming.
- Is a
ChildrenMixin
- Has one or more
StopNode
as children, defined as- Is a
MinimalFillsMixin
- Does not begin with
.
or_
- Has numeric name after trimming
- Is a
GenerateScaleOptions
Extract this information from the ScaleNode
before acting on it.
interface LightnessScaleProperties {
name: string;
theme: string | null;
min: number;
max: number;
keyLightest: string;
keyBase: string;
keyDarkest: string;
}
function generateLightnessScale(options: LightnessScaleProperties) {
throw new Error("not implemented")
}
Interpreting ScaleNode
theme
/scale
are extracted fromScaleNode
name match. (see RegExp pattern above)- theme is optional. If only the first match has a value, treat it as the scale's
name
- theme is optional. If only the first match has a value, treat it as the scale's
min
andmax
interpreted based on the numeric values of theStopNode
names. If allStopNode
s have a name with a numberic value value...if largest < 10
: the scale is interpreted to be in the range [0, 1000], otherwiseif largest < 100
: range is [0, 100], otherwiseif largest < 1000
is [0, 1000]
lightestColor
anddarkestColor
are the lightest colors amongStopNode
that aren't pure white or black, respectively (since white and black are intrinsically devoid of hue or saturation information)
Scale
and Stop
interface Stop {
name: string;
offset: number; // in the range [0,1]
color: RGB;
}
interface LightnessScale extends LightnessScaleProperties {
stops: Stop[]
}
Generate lightness scale (HSLuv linear interpolation)
Generate a lightness scale using linear interpolation between referenceLightest, referenceDarkest, and referenceBase, based on the HSLuv lightness of each of the reference points.
See this function for a start
Clean scale styles before generating new ones
Generate lightness scale (HSLuv quadratic bezier interpolation)
Generate scale from gradient
Element with gradient should have name like
[<folder> / ] <scale> [ / <stop-list>]
- allow arbitrary whitespece
- where
<stop-list>
is like{50, 100, 200, 300, 400, 500, 600, 700, 800, 900}
- if is omitted, use
{100, 200, 300, 400, 500, 600, 700, 800, 900}
Sample each stop value (normalized to the implied maximum power of 10 among all stop values) and create a style
Create a reference-gradient
style and assign it to the element
Split off:
Find matching scale styles by name more robustly
Should match the scale style name more forgivingly
- Allow arbitrary whitespace
Swap: Color
Write a command with parameters
- That allows a user to switch scales, while preserving stops.
- The command should provide completions based on known scales.
- It should allow free-form submission, that is treated as the top match among completions for more intuitive use.
Decisions
- What is a "scale"?
- How do we filter what to show in completions?
Fix Gradient Lightness: Flip lightness on gradient based on original order of stops
Named stops for scale stops
labeled stops can be specified like {lightest=50, 100, 200, ...}
: the stop will be named as the identifier and treated as the number
Proper gamut clipping when converting from LCH to RGB
Currently, we are just clamping each channel value. Really, we should us hsluv to find the maximum possible lch and clamp to that.
Generate lightness scale (LCH interpolation, clamped to RGB gamut)
Fix gradient lightness: smarter decision about middle stop
Need to be a little smarter about how the middle stop is decided.
- If a stop's color matches the DEFAULT color for the existing scale, use that value
- Otherwise, use the most chromatic stop
Simplify scale configuration
Configuration mostly by naming convention
- Reference scale: must be present, with a name matching
/[._]?scale$/i
- Base color: optional, but will be interpreted and generated if not present. name must match
/[._]?(?:base|default|normal)$/i
- Stops: a style in a folder containing a reference scale. Description must match
/^([\d.])+%/
. The style will sample the gradient at an offset ofNumber($1) / 100
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.