diff --git a/lib/documentation/index.js b/lib/documentation/index.js index 251bd66546f6..7d9f525470c2 100644 --- a/lib/documentation/index.js +++ b/lib/documentation/index.js @@ -1,10 +1,12 @@ const api = require('../../packages/main/dist/api.json'); +const cssVariables = require('../../packages/main/docs/themes/css-vars.json'); const template = require('./templates/template').template; const sinceTemplate = require('./templates/api-component-since').template; const propertiesTemplate = require('./templates/api-properties-section').template; const slotsTemplate = require('./templates/api-slots-section').template; const eventsTemplate = require('./templates/api-events-section').template; const methodsTemplate = require('./templates/api-methods-section').template; +const cssVariablesTemplate = require('./templates/api-css-variables-section').template; const Handlebars = require('handlebars/dist/handlebars.min.js'); const fs = require('fs'); const mkdirp = require('mkdirp'); @@ -18,7 +20,11 @@ const sinceMarker = ""; const getComponentByName = name => { return entries.find(element => { return element.basename === name; - }) + }) +}; + +const getCSSVarsByName = name => { + return cssVariables[name] || []; }; const capitalize = str => { @@ -42,23 +48,34 @@ Handlebars.registerPartial('properties', propertiesTemplate); Handlebars.registerPartial('slots', slotsTemplate); Handlebars.registerPartial('events', eventsTemplate); Handlebars.registerPartial('methods', methodsTemplate); +Handlebars.registerPartial('cssVariables', cssVariablesTemplate); mkdirp(`dist/test-resources/sap/ui/webcomponents/main/api`); let entriesAPI = []; -const mergeParentAPI = entry => { +const appendCSSVarsAPI = entry => { + entry.cssVariables = getCSSVarsByName(entry.basename); + return entry; +} + +const calculateAPI = entry => { if (entriesAPI.indexOf(entry.basename) !== -1) { return entry; } let parent = getComponentByName(entry.extends) || {}; - parent = { ...{ properties: [], events: [], slots: [] }, ...parent }; + + entry = appendCSSVarsAPI(entry); + parent = appendCSSVarsAPI(parent); + + parent = { ...{ properties: [], events: [], slots: [], cssVariables: [] }, ...parent }; // extend component documentation entry.properties = [...(entry.properties || []), ...(parent.properties || [])]; entry.events = [...(entry.events || []), ...(parent.events || [])]; entry.slots = [...(entry.slots || []), ...(parent.slots || [])]; + entry.cssVariables = [...(entry.cssVariables || []), ...(parent.cssVariables || [])]; entriesAPI.push(entry.basename); @@ -72,7 +89,7 @@ const appendAdditionalEntriesAPI = entry => { additionalEntries.forEach(entryName => { let additionalEntry = getComponentByName(entryName); - additionalEntry = mergeParentAPI(additionalEntry); + additionalEntry = calculateAPI(additionalEntry); entry.additionalDocs.push(additionalEntry); }); } @@ -120,10 +137,10 @@ const generateSamplePage = entry => { } const generateComponentAPI = entry => { - // (1) merge parent API - entry = mergeParentAPI(entry); + // (1) calculate the API + entry = calculateAPI(entry); - // (2) append additional API for children + // (2) append additional API for composition components - List -> ListIems, TabContainer -> Tabs, Table -> TableRow/Column/Cell entry = appendAdditionalEntriesAPI(entry); // (3) generate sample page diff --git a/lib/documentation/templates/api-css-variables-section.js b/lib/documentation/templates/api-css-variables-section.js new file mode 100644 index 000000000000..d886fe617bbe --- /dev/null +++ b/lib/documentation/templates/api-css-variables-section.js @@ -0,0 +1,24 @@ +module.exports = { + template: ` + {{#if cssVariables}} +

CSS variables

+

You can use the following CSS varialbes to change the component styling.

+ +
+
+
Name
+
Description
+
+ + {{#each cssVariables}} +
+
{{this.name}}
+
+ {{{this.description}}} +
+
+ {{/each}} + +
+ {{/if}}` +}; \ No newline at end of file diff --git a/lib/documentation/templates/template.js b/lib/documentation/templates/template.js index 2137f50982f1..69754a936d07 100644 --- a/lib/documentation/templates/template.js +++ b/lib/documentation/templates/template.js @@ -9,6 +9,7 @@ module.exports = { {{> slots this}} {{> events this}} {{> methods this}} + {{> cssVariables this}} @@ -21,7 +22,8 @@ module.exports = {
{{> properties this}} {{> slots this}} - {{> events this}} + {{> events this}} + {{> cssVariables this}}
diff --git a/packages/main/docs/themes/css-vars.json b/packages/main/docs/themes/css-vars.json new file mode 100644 index 000000000000..f172a06f9213 --- /dev/null +++ b/packages/main/docs/themes/css-vars.json @@ -0,0 +1,24 @@ +{ + "GroupHeaderListItem": [ + { + "name": "--ui5-group-header-listitem-background-color", + "description": "Defines the ui5-li-groupheader background color" + } + ], + "ListItem": [ + { + "name": "--ui5-listitem-background-color", + "description": "Defines theui5-li background color" + } + ], + "Panel": [ + { + "name": "--ui5-panel-background-color", + "description": "Defines the ui5-panel background color" + }, + { + "name": "--ui5-panel-bottom-border-color", + "description": "Defines the ui5-panel bottom border color" + } + ] +} \ No newline at end of file diff --git a/packages/main/src/themes/GroupHeaderListItem.css b/packages/main/src/themes/GroupHeaderListItem.css index 0e276e42ba85..04b5edee60cc 100644 --- a/packages/main/src/themes/GroupHeaderListItem.css +++ b/packages/main/src/themes/GroupHeaderListItem.css @@ -1,7 +1,7 @@ .sapMLIB.sapMGHLI { height: 3rem; color: var(--sapUiListTableGroupHeaderTextColor); - background: var(--_ui5_group_header_listitem_background_color); + background: var(--ui5-group-header-listitem-background-color); padding-top: 1rem; font-size: var(--sapMFontHeader6Size); font-weight: var(--sapUiFontHeaderWeight); diff --git a/packages/main/src/themes/ListItemBase.css b/packages/main/src/themes/ListItemBase.css index bea5c44c9660..b43460ce5904 100644 --- a/packages/main/src/themes/ListItemBase.css +++ b/packages/main/src/themes/ListItemBase.css @@ -21,7 +21,7 @@ ui5-li .sap-phone .sapMLIB { height: 3rem; width: 100%; padding: 0 1rem 0 1rem; - background: var(--_ui5_listitem_background_color); + background: var(--ui5-listitem-background-color); box-sizing: border-box; } diff --git a/packages/main/src/themes/Panel.css b/packages/main/src/themes/Panel.css index 39798711a670..a68d4846f30a 100644 --- a/packages/main/src/themes/Panel.css +++ b/packages/main/src/themes/Panel.css @@ -12,7 +12,7 @@ ui5-panel { overflow: hidden; box-sizing: border-box; position: relative; - background-color: var(--_ui5_panel_background_color); + background-color: var(--ui5-panel-background-color); } .sapMPanel > header { @@ -77,7 +77,7 @@ ui5-panel { box-sizing: border-box; overflow: auto; white-space: normal; - border-bottom: 1px solid var(--_ui5_panel_bottom_border_color); + border-bottom: 1px solid var(--ui5-panel-bottom-border-color); } .sapMPanelContent:focus { @@ -87,7 +87,7 @@ ui5-panel { .sapMPanelWrappingDiv, .sapMPanelWrappingDivTb { position: relative; - background-color: var(--_ui5_panel_background_color); + background-color: var(--ui5-panel-background-color); } .sapMPanelWrappingDiv { diff --git a/packages/main/src/themes/base/GroupHeaderListItem-parameters.css b/packages/main/src/themes/base/GroupHeaderListItem-parameters.css index 335cbaa8945c..dbe67e31aab5 100644 --- a/packages/main/src/themes/base/GroupHeaderListItem-parameters.css +++ b/packages/main/src/themes/base/GroupHeaderListItem-parameters.css @@ -1,3 +1,3 @@ :root { - --_ui5_group_header_listitem_background_color: var(--sapUiListGroupHeaderBackground); + --ui5-group-header-listitem-background-color: var(--sapUiListGroupHeaderBackground); } \ No newline at end of file diff --git a/packages/main/src/themes/base/ListItemBase-parameters.css b/packages/main/src/themes/base/ListItemBase-parameters.css index 84a5bd6b7ab6..d1ff1ff94871 100644 --- a/packages/main/src/themes/base/ListItemBase-parameters.css +++ b/packages/main/src/themes/base/ListItemBase-parameters.css @@ -1,4 +1,4 @@ :root { + --ui5-listitem-background-color: var(--sapUiListBackground); --_ui5_listitembase_focus_width: 1px; - --_ui5_listitem_background_color: var(--sapUiListBackground); } \ No newline at end of file diff --git a/packages/main/src/themes/base/Panel-parameters.css b/packages/main/src/themes/base/Panel-parameters.css index 5ef865124e98..ce8be14ed50c 100644 --- a/packages/main/src/themes/base/Panel-parameters.css +++ b/packages/main/src/themes/base/Panel-parameters.css @@ -1,5 +1,5 @@ :root { + --ui5-panel-background-color: var(--sapUiGroupContentBackground); + --ui5-panel-bottom-border-color: var(--sapUiGroupTitleBorderColor); --_ui5_panel_focus_border: 1px dotted var(--sapUiContentFocusColor); - --_ui5_panel_background_color: var(--sapUiGroupContentBackground); - --_ui5_panel_bottom_border_color: var(--sapUiGroupTitleBorderColor); } \ No newline at end of file