-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-24 [flex] script, model, and configuration
- makes responsive configuration more complex, - makes style guide more abstract, with colors and gradient, - adds a FlexModel.getId, even if we might want to move this to some abstract model later, - introduces InlineStyleService that dynamically binds to InlineStyleWorker instances that each outputs inline style in context with the component, and the responsive layout, - introduces generic InlineStyleWorkers for border, color, shadow, background-*, - introduces specific InlineStyleWorkers for flex specific rules, - adds a FlexModel.getStyle that reuses the above, - adds conf + content for dx-docs, that should have a hello world flex usage at /content/dx-docs/us/en.html - adds testing-extension module that allows easy UT of models with all of the above
- Loading branch information
Showing
87 changed files
with
3,170 additions
and
216 deletions.
There are no files selected for viewing
This file contains 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
5 changes: 5 additions & 0 deletions
5
...t/apps/dx-docs/configs/config.author/com.adobe.dx.domtagging.internal.IDTaggerImpl.config
This file contains 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,5 @@ | ||
acceptedTypes=["dx/structure/.*","dx-docs/components/.*"] | ||
tagOnPublication=B"true" | ||
tagOnModification=B"true" | ||
referenceTypes=["cq/experience-fragments/editor/components/experiencefragment"] | ||
shouldRewriteComponentHash=B"true" |
1 change: 0 additions & 1 deletion
1
...app/jcr_root/apps/dx-docs/configs/config/com.adobe.dx.domtagging.internal.IDTagger.config
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...jcr_root/apps/dx-docs/configs/config/com.adobe.dx.domtagging.internal.IDTaggerImpl.config
This file contains 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 @@ | ||
acceptedTypes=["dx/structure/.*","dx-docs/components/.*"] |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -7,4 +7,6 @@ | |
jcr:primaryType="sling:OrderedFolder" | ||
jcr:title="DX"> | ||
<settings/> | ||
<_cq_styleguide/> | ||
<_sling_configs/> | ||
</jcr:root> |
3 changes: 3 additions & 0 deletions
3
apps/docs/content/jcr_root/conf/dx-docs/_sling_configs/.content.xml
This file contains 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,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="nt:unstructured"/> |
4 changes: 4 additions & 0 deletions
4
...ling_configs/com.adobe.dx.admin.rendercondition.RenderConditionConfiguration/.content.xml
This file contains 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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="nt:unstructured" | ||
passthroughGroups="[test,administrators]"/> |
29 changes: 29 additions & 0 deletions
29
.../conf/dx-docs/_sling_configs/com.adobe.dx.responsive.ResponsiveConfiguration/.content.xml
This file contains 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,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="nt:unstructured"> | ||
<jcr:content jcr:primaryType="nt:unstructured"> | ||
<breakpoints jcr:primaryType="nt:unstructured"> | ||
<mobile jcr:primaryType="nt:unstructured" | ||
end="{Long}599" | ||
key="mobile" | ||
label="Mobile / Default" | ||
propertySuffix="Mobile" | ||
start="{Long}0"/> | ||
<tablet jcr:primaryType="nt:unstructured" | ||
end="{Long}1199" | ||
key="tablet" | ||
label="Tablet" | ||
inheritProperty="inheritTablet" | ||
mediaQuery="@media only screen and (min-width: 600px)" | ||
propertySuffix="Tablet" | ||
start="{Long}600"/> | ||
<desktop jcr:primaryType="nt:unstructured" | ||
key="desktop" | ||
label="Desktop" | ||
inheritProperty="inheritDesktop" | ||
mediaQuery="@media only screen and (min-width: 1200px)" | ||
propertySuffix="Desktop" | ||
start="{Long}1200"/> | ||
</breakpoints> | ||
</jcr:content> | ||
</jcr:root> |
30 changes: 30 additions & 0 deletions
30
...tent/jcr_root/conf/dx-docs/_sling_configs/com.adobe.dx.styleguide.StyleGuide/.content.xml
This file contains 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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" | ||
jcr:primaryType="nt:unstructured"> | ||
<jcr:content jcr:primaryType="nt:unstructured"> | ||
<colors jcr:primaryType="nt:unstructured"> | ||
<red jcr:primaryType="nt:unstructured" | ||
value="#FE0000" | ||
key="red" | ||
label="Adobe Red"/> | ||
<blue jcr:primaryType="nt:unstructured" | ||
value="#0000FE" | ||
key="blue" | ||
label="Blue"/> | ||
<white jcr:primaryType="nt:unstructured" | ||
value="#FEFEFE" | ||
key="white" | ||
label="White"/> | ||
</colors> | ||
<gradients jcr:primaryType="nt:unstructured"> | ||
<red jcr:primaryType="nt:unstructured" | ||
value="linear-gradient(180deg, rgba(0, 0, 0, 0.5) 36.8%,rgba(255, 0, 0, 0.78) 95.0%)" | ||
key="red" | ||
label="Adobe Red"/> | ||
<white jcr:primaryType="nt:unstructured" | ||
value="linear-gradient(90deg, rgba(0, 0, 0, 0.5) 36.8%,rgba(255, 0, 0, 0.78) 95.0%)" | ||
key="another" | ||
label="Another Red"/> | ||
</gradients> | ||
</jcr:content> | ||
</jcr:root> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
100 changes: 100 additions & 0 deletions
100
apps/structure/core/src/main/java/com/adobe/dx/structure/flex/FlexGeneralStyle.java
This file contains 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,100 @@ | ||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
~ Copyright 2020 Adobe | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | ||
package com.adobe.dx.structure.flex; | ||
|
||
import static com.adobe.dx.inlinestyle.Constants.DEL_SPACE; | ||
import static com.adobe.dx.inlinestyle.Constants.RULE_DELIMITER; | ||
import static com.adobe.dx.structure.flex.FlexModel.PN_MINHEIGHT; | ||
import static com.adobe.dx.structure.flex.FlexModel.PN_MINHEIGHT_TYPE; | ||
|
||
import com.adobe.dx.inlinestyle.InlineStyleWorker; | ||
import com.adobe.dx.responsive.Breakpoint; | ||
import com.adobe.dx.utils.RequestUtil; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.sling.api.SlingHttpServletRequest; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.ConfigurationPolicy; | ||
|
||
/** | ||
* Sets up general inline style for items container (min height, and gap) | ||
*/ | ||
@Component(configurationPolicy = ConfigurationPolicy.REQUIRE) | ||
public class FlexGeneralStyle implements InlineStyleWorker { | ||
private static final String FLEX_GENERAL = "flex-general"; | ||
private static final String RULE_CONTAINER = "#%s > .dx-flex-items {\n%s\n}"; | ||
private static final String RULE_ITEM = "#%s > .dx-flex-items > * {\n%s\n}"; | ||
private static final String PN_GAP = "gap"; | ||
private static final String MIN_HEIGHT_PREFIX = "min-height: "; | ||
private static final String GAP_CONTAINER = "margin: -%spx"; | ||
private static final String GAP_ITEM_DECLARATION = "border: 0 solid transparent; border-width: %spx"; | ||
|
||
@Override | ||
public String getKey() { | ||
return FLEX_GENERAL; | ||
} | ||
|
||
@Override | ||
public @Nullable String getDeclaration(@Nullable Breakpoint breakpoint, SlingHttpServletRequest request) { | ||
return null; | ||
} | ||
|
||
String computeMinHeight(Breakpoint breakpoint, SlingHttpServletRequest request) { | ||
Long minHeight = RequestUtil.getFromRespProps(request, breakpoint, PN_MINHEIGHT, Long.class); | ||
if ( minHeight != null) { | ||
String minHeightType = RequestUtil.getFromRespProps(request, breakpoint, PN_MINHEIGHT_TYPE, String.class); | ||
if (minHeightType != null) { | ||
return MIN_HEIGHT_PREFIX + minHeight.toString() + minHeightType; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
String computeGapContainer(Long gap) { | ||
if (gap != null) { | ||
return String.format(GAP_CONTAINER, gap.toString()); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable String getRule(Breakpoint breakpoint, @Nullable String id, | ||
SlingHttpServletRequest request) { | ||
List<String> rules = null; | ||
String minHeight = computeMinHeight(breakpoint, request); | ||
Long gap = RequestUtil.getFromRespProps(request, breakpoint, PN_GAP, Long.class); | ||
gap = gap != null ? gap / 2 : null; | ||
String gapContainer = computeGapContainer(gap); | ||
if (StringUtils.isNotBlank(minHeight) || StringUtils.isNotBlank(gapContainer)) { | ||
rules = new ArrayList<>(); | ||
rules.add(String.format(RULE_CONTAINER, id, Arrays.asList(minHeight, gapContainer).stream() | ||
.filter(StringUtils::isNotBlank) | ||
.collect(Collectors.joining(DEL_SPACE)))); | ||
} | ||
if (gap != null) { | ||
rules = rules == null ? new ArrayList<>() : rules; | ||
rules.add(String.format(RULE_ITEM, id, String.format(GAP_ITEM_DECLARATION, gap.toString()))); | ||
} | ||
return rules != null ? String.join(RULE_DELIMITER, rules) : null; | ||
} | ||
|
||
} |
Oops, something went wrong.