Stylesheet

Node SDK CRUD Stylesheet

CRUD on Zesty.io stylesheet files.

All examples assume a properly authenticated SDK instance

Get all stylesheets

try {
  const res = await sdk.instance.getStylesheets();
} catch (err) {
  console.error(err);
}

Get a stylesheet by ZUID

try {
  const stylesheetZUID = "10-..."; // Stylesheet ZUIDs begin with 10
  const res = await sdk.instance.getStylesheet(stylesheetZUID);
} catch (err) {
  console.error(err);
}

Create a stylesheet

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);
}