Skip to content

Commit

Permalink
fix(docs): fix component styles table (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa authored and yggg committed May 31, 2019
1 parent 310127b commit ab166fd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/app/@theme/services/styles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class NgdStylesService {
}

mapThemedValues(classStyles: any): any {
const defaultTheme = this.docs.themes[DEFAULT_THEME_NAME].data;
const defaultTheme = this.docs.completeThemes[DEFAULT_THEME_NAME].data;

return classStyles.map(item => {
return item.styles.map(prop => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { NgdStylesService } from '../../../@theme/services';
<tbody>
<tr *ngFor="let item of style">
<td>{{ item.name }}</td>
<td>{{ item.parent || 'unknown' }}</td>
<td>{{ item.parent || '' }}</td>
<td ngdColorSwatch>{{ item.value || 'unknown' }}</td>
<td>
<p *ngIf="item.shortDescription" ngdDescription>{{ item.shortDescription}}</p>
Expand Down
3 changes: 2 additions & 1 deletion docs/themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ $nb-theme-export-mode: true;

@import '../src/framework/theme/styles/theming';
@import '../src/framework/theme/styles/themes';
@import '../src/framework/theme/styles/themes/mapping';

$v: export('output.json', $nb-themes-export, (prefix:'', suffix:''));
$v: export('output.json', $nb-themes-export, $eva-mapping);
35 changes: 25 additions & 10 deletions scripts/gulp/tasks/docs/export-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ const exporter = {
result = exporter.getParent(prop, themeName, themeName, prop, result, THEMES);
});
});
const output = {};
output['themes'] = result;
return output;

return result;
},

getParent(prop, scopedThemeName, resultThemeName, resultProp, resultObj, THEMES) {
Expand Down Expand Up @@ -120,19 +119,35 @@ const exporter = {


function(path) {
return function (file, value, options) {
const opt = _.defaults(exporter.get_value(options), { prefix: '', suffix: '', extend: false });
let output = exporter.get_value(value);
output = exporter.parseThemes(output);
return function (file, themes, mapping) {
const themesValue = exporter.get_value(themes);
const mappingValue = exporter.get_value(mapping);

const completeThemes = {};
Object.keys(themesValue).forEach((themeName) => {
const theme = themesValue[themeName];
completeThemes[themeName] = {
...theme,
data: _.defaults(mappingValue, theme.data),
};
});


let output = {
themes: exporter.parseThemes(themesValue),
// TODO: we need to change internal function interface as it very hard to re-use them
completeThemes: exporter.parseThemes(completeThemes),
};

output = _.defaults(JSON.parse(fs.readFileSync(path + '/' + file.getValue())), output);
fs.writeFileSync(path + '/' + file.getValue(), opt.prefix + JSON.stringify(output, null, ' ') + opt.suffix);
return value;
fs.writeFileSync(path + '/' + file.getValue(), JSON.stringify(output, null, ' '));
return themes;
}
},

interface(name) {
name = name || 'export';
return name + '($file, $value, $options:())';
return name + '($file, $themes, $mapping)';
},
};

Expand Down

0 comments on commit ab166fd

Please sign in to comment.