-
Notifications
You must be signed in to change notification settings - Fork 0
Slider, range and color arguments #82
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
Open
kamil-orwat-vmltech
wants to merge
15
commits into
main
Choose a base branch
from
slider-range-and-color-arguments
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4c1b285
Slider, range and color arguments
kamil-orwat-vmltech 53b1d20
formatting
kamil-orwat-vmltech 802ee56
Improved documentation
kamil-orwat-vmltech acac1ff
removed useless code
kamil-orwat-vmltech d51ccb8
Merge remote-tracking branch 'origin/main' into slider-range-and-colo…
krystian-panek-vmltech 8b95ad2
Bundle up fix
krystian-panek-vmltech 03d92ce
Bug fixes, Jackson private
krystian-panek-vmltech 87413e2
extended color arg and renamed slider to number and range to numberrange
kamil-orwat-vmltech 006f142
Merge branch 'main' into slider-range-and-color-arguments
kamil-orwat-vmltech b887c02
changes from review
kamil-orwat-vmltech e70503f
refactored inputs
kamil-orwat-vmltech af304f4
formattings + cleanup
kamil-orwat-vmltech 23806cc
Implemented changes from CR
kamil-orwat-vmltech df8f74d
Merge branch 'main' into slider-range-and-color-arguments
<
8000
/div>
kamil-orwat-vmltech May 12, 2025
f9d692f
formatting
kamil-orwat-vmltech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,7 @@ public enum ArgumentType { | |
STRING, | ||
TEXT, | ||
SELECT, | ||
MULTISELECT | ||
MULTISELECT, | ||
COLOR, | ||
NUMBER_RANGE | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/com/vml/es/aem/acm/core/code/arg/ColorArgument.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.vml.es.aem.acm.core.code.arg; | ||
|
||
import com.vml.es.aem.acm.core.code.Argument; | ||
import com.vml.es.aem.acm.core.code.ArgumentType; | ||
import java.util.Arrays; | ||
|
||
public class ColorArgument extends Argument<String> { | ||
private ColorArgument.Format format = ColorArgument.Format.RGBA; | ||
|
||
public ColorArgument(String name) { | ||
super(name, ArgumentType.COLOR); | ||
} | ||
|
||
public Format getFormat() { | ||
return format; | ||
} | ||
|
||
public void setFormat(String format) { | ||
this.format = ColorArgument.Format.of(format); | ||
} | ||
|
||
public void setFormat(ColorArgument.Format format) { | ||
this.format = format; | ||
} | ||
|
||
public void hex() { | ||
this.format = ColorArgument.Format.HEX; | ||
} | ||
|
||
public void hsl() { | ||
this.format = ColorArgument.Format.HSL; | ||
} | ||
|
||
public void rgba() { | ||
this.format = ColorArgument.Format.RGBA; | ||
} | ||
|
||
public void hsb() { | ||
this.format = ColorArgument.Format.HSB; | ||
} | ||
|
||
public enum Format { | ||
HEX, | ||
HSL, | ||
RGBA, | ||
HSB; | ||
|
||
public static ColorArgument.Format of(String name) { | ||
return Arrays.stream(ColorArgument.Format.values()) | ||
.filter(r -> r.name().equalsIgnoreCase(name)) | ||
.findFirst() | ||
.orElseThrow(() -> | ||
new IllegalArgumentException(String.format("Color format '%s' is not supported!", name))); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
core/src/main/java/com/vml/es/aem/acm/core/code/arg/DecimalRangeArgument.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.vml.es.aem.acm.core.code.arg; | ||
|
||
import com.vml.es.aem.acm.core.code.Argument; | ||
import com.vml.es.aem.acm.core.code.ArgumentType; | ||
import com.vml.es.aem.acm.core.util.RangeArgumentObject; | ||
import java.math.BigDecimal; | ||
import java.util.List; | ||
|
||
public class DecimalRangeArgument extends Argument<RangeArgumentObject<BigDecimal>> { | ||
private BigDecimal min; | ||
|
||
private BigDecimal max; | ||
|
||
private BigDecimal step; | ||
|
||
public DecimalRangeArgument(String name) { | ||
super(name, ArgumentType.NUMBER_RANGE); | ||
} | ||
|
||
public void setValue(List<BigDecimal> value) { | ||
if (value.size() != 2) { | ||
throw new IllegalArgumentException( | ||
String.format("Range value must be a list of two elements but specified '%s'!", value)); | ||
} | ||
super.setValue(new RangeArgumentObject<>(value.get(0), value.get(1))); | ||
} | ||
|
||
public BigDecimal getMin() { | ||
return min; | ||
} | ||
|
||
public void setMin(BigDecimal min) { | ||
this.min = min; | ||
} | ||
|
||
public BigDecimal getStep() { | ||
return step; | ||
} | ||
|
||
public void setStep(BigDecimal step) { | ||
this.step = step; | ||
} | ||
|
||
public BigDecimal getMax() { | ||
return max; | ||
} | ||
|
||
public void setMax(BigDecimal max) { | ||
this.max = max; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/src/main/java/com/vml/es/aem/acm/core/code/arg/IntegerRangeArgument.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.vml.es.aem.acm.core.code.arg; | ||
|
||
import com.vml.es.aem.acm.core.code.Argument; | ||
import com.vml.es.aem.acm.core.code.ArgumentType; | ||
import com.vml.es.aem.acm.core.util.RangeArgumentObject; | ||
import java.util.List; | ||
|
||
public class IntegerRangeArgument extends Argument<RangeArgumentObject<Integer>> { | ||
private Integer min; | ||
|
||
private Integer max; | ||
|
||
private Integer step; | ||
|
||
public IntegerRangeArgument(String name) { | ||
super(name, ArgumentType.NUMBER_RANGE); | ||
} | ||
|
||
public void setValue(List<Integer> value) { | ||
if (value.size() != 2) { | ||
throw new IllegalArgumentException( | ||
String.format("Range value must be a list of two elements but specified '%s'!", value)); | ||
} | ||
super.setValue(new RangeArgumentObject<>(value.get(0), value.get(1))); | ||
} | ||
|
||
public Integer getMin() { | ||
return min; | ||
} | ||
|
||
public void setMin(Integer min) { | ||
this.min = min; | ||
} | ||
|
||
public Integer getStep() { | ||
return step; | ||
} | ||
|
||
public void setStep(Integer step) { | ||
this.step = step; | ||
} | ||
|
||
public Integer getMax() { | ||
return max; | ||
} | ||
|
||
public void setMax(Integer max) { | ||
this.max = max; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
core/src/main/java/com/vml/es/aem/acm/core/util/RangeArgumentObject.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.vml.es.aem.acm.core.util; | ||
|
||
import java.io.Serializable; | ||
|
||
public class RangeArgumentObject<T extends Comparable<T>> implements Serializable { | ||
private T start; | ||
|
||
private T end; | ||
|
||
public RangeArgumentObject(T start, T end) { | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
public T getStart() { | ||
return start; | ||
} | ||
|
||
public void setStart(T start) { | ||
this.start = start; | ||
} | ||
|
||
public T getEnd() { | ||
return end; | ||
} | ||
|
||
public void setEnd(T end) { | ||
this.end = end; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ent/src/main/content/jcr_root/conf/acm/settings/snippet/available/core/argument/color.yml
D551
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
group: Argument | ||
name: argument_color | ||
content: | | ||
args.color("${1:name}") { label = "${2:label}"; value = ${3:value} } | ||
documentation: | | ||
An argument that allows to choose a value from color picker.<br> | ||
It returns a string with the color in selected format, RGBA is the default<br> | ||
<br> | ||
**Example**:<br> | ||
```groovy | ||
args.color("color") { label = "background color"; value = "#ff0000"; hex() } | ||
``` |
9 changes: 5 additions & 4 deletions
9
...t/src/main/content/jcr_root/conf/acm/settings/snippet/available/core/argument/decimal.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
group: Argument | ||
name: argument_decimal | ||
content: | | ||
args.decimalNumber("${1:name}") { label = "${2:label}"; value = "${3:value}" } | ||
args.decimalNumber("${1:name}") { label = "${2:label}"; value = ${3:value} } | ||
documentation: | | ||
An argument holding a decimal number value.<br> | ||
|
||
For example: | ||
can be displayed as an input and slider.<br> | ||
**Example**:<br> | ||
```groovy | ||
args.decimalNumber("discount") { label = "Discount (%)"; value = 15.5 } | ||
args.decimalNumber("weight") { label = "Weight (kg)"; value = 75.3 } | ||
``` | ||
args.decimalNumber("proportion") { label = "Proportion"; value = 20.00; min = 10.00; max = 60.00; step = 0.5; slider() } | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
will it work with ints, doubles, strings when passed from groovy?
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.
nope, only decimals, but I think it's expected if we want type safety?