Skip to content
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

Add DSP basic export #5

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 29 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<pre v-if="selectedOption === 0"><code v-highlight class="json" v-html="JSON.stringify(transformW3C(),null,2)"></code></pre>
<pre v-if="selectedOption === 1"><code v-highlight class="css" v-html="transformCSSvars('CSS')"></code></pre>
<pre v-if="selectedOption === 2"><code v-highlight class="scss" v-html="transformCSSvars('SASS')"></code></pre>
<pre v-if="selectedOption === 3"><code v-highlight class="css" v-html="transformDSP()"></code></pre>
<pre v-if="selectedOption === 3"><code v-highlight class="json" v-html="transformDSP()"></code></pre>
<pre v-if="selectedOption === 4">
<div class="theo-specs-radio">
<div>
Expand Down Expand Up @@ -267,7 +267,7 @@ export default {
{
$name: "easeInSine",
"$value": "cubic-bezier(0.12, 0, 0.39, 0)"
},
},
{
$name: "easeOutSine",
"$value": "cubic-bezier(0.61, 1, 0.88, 1)500ms"
Expand Down Expand Up @@ -417,7 +417,33 @@ export default {
},
methods: {
transformDSP() {
return "{ DSP Support coming soon! }"
const now = (new Date()).toISOString();
const updatedBy = "Layoutit" // or Design Tokens Generator
var newObj = {
dsp_spec_version: "1.0",
last_updated_by: updatedBy,
last_updated: now,
settings: {},
entities: []
};
var copyObj = JSON.parse(JSON.stringify(this.sets[this.selectedToken]));
for (const group of copyObj.tokens) {
for (const token of group.tokens) {
const { $type } = group;
const type = ($type === "color" || $type === "size") ? $type : "custom";
const entity = {
class: "token",
type,
id: `${group.$type}_${token.$name}`,
value: token.$value,
last_updated: now,
last_updated_by: updatedBy,
description: token.$description || "",
};
newObj.entities.push(entity);
}
}
return newObj;
},
transformTheo(format) {
var newObj = { props: {} };
Expand Down