sanity-plugin-grid
Version:
A custom input component for displaying an array of grid objects.
101 lines (90 loc) • 2.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _lib = _interopRequireDefault(require("../lib"));
var _sanityPluginTabs = _interopRequireDefault(require("sanity-plugin-tabs"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var customFields = [{
title: "Title",
name: "username",
type: "string"
}, {
title: "Grid Image",
name: "gridimg",
type: "image"
}];
try {
customFields = require("../../../sanitygrid")["default"];
console.log("CUSTOM FIELDS: ", customFields);
} catch (e) {
if (e instanceof Error && e.code === "MODULE_NOT_FOUND") console.log("Can't load foo!");else throw e;
}
var gridItemBase = [{
title: "Width",
description: "Width in number of columns.",
name: "width",
type: "number"
}, {
title: "Height",
description: "Height in number of rows.",
name: "height",
type: "number"
}, {
title: "Column",
description: "What column to position the item at.",
name: "posX",
type: "number"
}, {
title: "Row",
description: "What row to position the item at.",
name: "posY",
type: "number"
}];
var _default = {
title: "Sanity Grid",
name: "sanitygrid",
type: "object",
inputComponent: _sanityPluginTabs["default"],
fieldsets: [{
name: "content",
title: "Content"
}, {
name: "settings",
title: "Settings"
}],
fields: [// Grid Item
{
fieldset: "content",
name: "grid",
type: "array",
of: [{
title: "Grid Item",
name: "griditem",
type: "object",
fields: [].concat(_toConsumableArray(customFields), [{
name: "settings",
type: "object",
fields: [].concat(gridItemBase)
}])
}],
inputComponent: _lib["default"]
}, // Grid Settings
{
title: "Columns",
name: "columns",
fieldset: "settings",
type: "number"
}, {
title: "Rows",
name: "rows",
fieldset: "settings",
type: "number"
}]
};
exports["default"] = _default;