CRUD on Zesty.io stylesheet files.
try {
const res = await sdk.instance.getStylesheets();
} catch (err) {
console.error(err);
}
try {
const stylesheetZUID = "10-..."; // Stylesheet ZUIDs begin with 10
const res = await sdk.instance.getStylesheet(stylesheetZUID);
} catch (err) {
console.error(err);
}
const fileName = "styles.less";
const code = ".myClass { text-align: left; }";
const stylesheetType = "text/less"; // Can also use text/css, text/sass or text/scss
const payload = {
code: code,
fileName: fileName,
type: stylesheetType
};
try {
const res = await sdk.instance.createStylesheet(payload);
} catch (err) {
console.error(err);
}
Save a stylesheet: Change the contents of a stylesheet, while retaining the filename and file type.
const stylesheetZUID = "10-...";
const code = ".anotherClass { text-align: center; }";
const payload = {
code: code
};
try {
const res = await sdk.instance.saveStylesheet(stylesheetZUID, payload);
} catch (err) {
console.error(err);
}