-
Notifications
You must be signed in to change notification settings - Fork 664
feat: add ability to fade multiple #2509
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
base: master
Are you sure you want to change the base?
Changes from all commits
af5b671
9ea469a
faa8c41
da130c7
7e3fbd7
e73a58d
871978c
8bacca9
8083fb2
45f038c
8fb989d
ffb39df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,26 +281,27 @@ func (r Reference) InEdge() bool { | |
| } | ||
|
|
||
| type Style struct { | ||
| Opacity *Scalar `json:"opacity,omitempty"` | ||
| Stroke *Scalar `json:"stroke,omitempty"` | ||
| Fill *Scalar `json:"fill,omitempty"` | ||
| FillPattern *Scalar `json:"fillPattern,omitempty"` | ||
| StrokeWidth *Scalar `json:"strokeWidth,omitempty"` | ||
| StrokeDash *Scalar `json:"strokeDash,omitempty"` | ||
| BorderRadius *Scalar `json:"borderRadius,omitempty"` | ||
| Shadow *Scalar `json:"shadow,omitempty"` | ||
| ThreeDee *Scalar `json:"3d,omitempty"` | ||
| Multiple *Scalar `json:"multiple,omitempty"` | ||
| Font *Scalar `json:"font,omitempty"` | ||
| FontSize *Scalar `json:"fontSize,omitempty"` | ||
| FontColor *Scalar `json:"fontColor,omitempty"` | ||
| Animated *Scalar `json:"animated,omitempty"` | ||
| Bold *Scalar `json:"bold,omitempty"` | ||
| Italic *Scalar `json:"italic,omitempty"` | ||
| Underline *Scalar `json:"underline,omitempty"` | ||
| Filled *Scalar `json:"filled,omitempty"` | ||
| DoubleBorder *Scalar `json:"doubleBorder,omitempty"` | ||
| TextTransform *Scalar `json:"textTransform,omitempty"` | ||
| Opacity *Scalar `json:"opacity,omitempty"` | ||
| Stroke *Scalar `json:"stroke,omitempty"` | ||
| Fill *Scalar `json:"fill,omitempty"` | ||
| FillPattern *Scalar `json:"fillPattern,omitempty"` | ||
| StrokeWidth *Scalar `json:"strokeWidth,omitempty"` | ||
| StrokeDash *Scalar `json:"strokeDash,omitempty"` | ||
| BorderRadius *Scalar `json:"borderRadius,omitempty"` | ||
| Shadow *Scalar `json:"shadow,omitempty"` | ||
| ThreeDee *Scalar `json:"3d,omitempty"` | ||
| Multiple *Scalar `json:"multiple,omitempty"` | ||
| MultipleOpacity *Scalar `json:"multipleOpacity,omitempty"` | ||
| Font *Scalar `json:"font,omitempty"` | ||
| FontSize *Scalar `json:"fontSize,omitempty"` | ||
| FontColor *Scalar `json:"fontColor,omitempty"` | ||
| Animated *Scalar `json:"animated,omitempty"` | ||
| Bold *Scalar `json:"bold,omitempty"` | ||
| Italic *Scalar `json:"italic,omitempty"` | ||
| Underline *Scalar `json:"underline,omitempty"` | ||
| Filled *Scalar `json:"filled,omitempty"` | ||
| DoubleBorder *Scalar `json:"doubleBorder,omitempty"` | ||
| TextTransform *Scalar `json:"textTransform,omitempty"` | ||
| } | ||
|
|
||
| // NoneTextTransform will return a boolean if the text should not have any | ||
|
|
@@ -486,6 +487,15 @@ func (s *Style) Apply(key, value string) error { | |
| return fmt.Errorf(`expected "text-transform" to be one of (%s)`, strings.Join(d2ast.TextTransforms, ", ")) | ||
| } | ||
| s.TextTransform.Value = value | ||
| case "multipleopacity": | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where does this come from?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we only have access to the key and value in the Apply function, if we pass only the "opacity" keyword as the key, there’s no way to distinguish whether it specifies the global-level opacity or multiple opacity. |
||
| if s.MultipleOpacity == nil { | ||
| break | ||
| } | ||
| f, err := strconv.ParseFloat(value, 64) | ||
| if err != nil || (f < 0 || f > 1) { | ||
| return errors.New(`expected "opacity" to be a number between 0.0 and 1.0`) | ||
| } | ||
| s.MultipleOpacity.Value = value | ||
| default: | ||
| return fmt.Errorf("unknown style key: %s", key) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be a code smell to you that you need this much extra code. There's a more precise place to make these changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can simplify the process by modifying
d2/d2compiler/compile.go
Lines 788 to 792 in b2841d5
as:
However, as it’s not possible to get the parent field of a particular field, we need to pass a new parameter to
d2/d2compiler/compile.go
Line 794 in b2841d5
to identify the parent field for opacity.