Public
Edited
Feb 7, 2023
Fork of DIY inputs
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// select({
// title: "JUMPING SELECT",
// desc: "AAAAND HOP!",
// options: {
// GREEN: "#A1E8CC",
// APRICOT: "#FAC9B8",
// BLUE: "#BFD4FF"
// },
// selectStyle: {
// background: "#A1E8CC"
// },
// onchange: ({ select, value }) =>
// d3
// .select(select)
// .style("font-size", "0px")
// .interrupt()
// .transition()
// .ease(d3.easePoly)
// .duration(250)
// .style("width", "100px")
// .style("height", "35px")
// .style("margin", "15px")
// .transition()
// .ease(d3.easeBounce)
// .duration(250)
// .style("width", "100px")
// .style("height", "30px")
// .style("margin", "0px")
// .style("background", value)
// .style("font-size", "12px")
// })
Insert cell
// select({
// title: "SHRINKING SELECT",
// desc: "AAAAND SHRINK!",
// options: {
// APRICOT: "#FAC9B8",
// GREEN: "#A1E8CC",
// BLUE: "#BFD4FF"
// },
// selectStyle: {
// background: "#FAC9B8"
// },
// onchange: ({ select, value }) =>
// d3
// .select(select)
// .style("font-size", "0px")
// .interrupt()
// .transition()
// .ease(d3.easePoly)
// .duration(250)
// .style("width", "10px")
// .style("height", "90px")
// .transition()
// .ease(d3.easeBounce)
// .duration(250)
// .style("width", "100px")
// .style("height", "30px")
// .style("background", value)
// .style("font-size", "12px")
// })
Insert cell
// select({
// title: "MY-FATHER-WAS-A-CIRCLE SELECT",
// desc: "NO JOKES.",
// options: {
// BLUE: "#BFD4FF",
// GREEN: "#A1E8CC",
// APRICOT: "#FAC9B8"
// },
// selectStyle: {
// background: "#BFD4FF"
// },
// onchange: ({ select, value }) =>
// d3
// .select(select)
// .style("font-size", "0px")
// .interrupt()
// .transition()
// .ease(d3.easePoly)
// .duration(350)
// .style("width", "100px")
// .style("height", "100px")
// .style("border-radius", "50px")
// .transition()
// .ease(d3.easeBounce)
// .duration(250)
// .style("width", "100px")
// .style("height", "30px")
// .style("border-radius", "5px")
// .style("background", value)
// .style("font-size", "12px")
// })
Insert cell
// select({
// title: "SPINNING SELECT",
// desc: "LET'S ROLL!",
// options: {
// I: "SPIN",
// LIKE: "TO",
// TOOOOO: "LIKE",
// SPIN: "I"
// },
// selectStyle: {
// background: "#FF72AF"
// },
// divStyle: {
// width: "160px",
// "font-size": "1px"
// },
// theme: "white",
// onchange: ({ div }) =>
// d3
// .select(div)
// .transition()
// .duration(250)
// .style("transform", `rotate(300deg)`)
// .transition()
// .ease(d3.easeBounce)
// .duration(750)
// .style("transform", `rotate(0deg)`)
// })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof dd = select({
options: num,
// value:null,
selectStyle: {
background: "#A1E8CC"
}
})
Insert cell
num=[null,"stuff","other"]
Insert cell
dd
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
select = (settings = {}) => {
// console.log(settings.options)
if (
typeof settings.options != "object" ||
Object.keys(settings.options).length == 0
) {
return "Please provide at least one option!";
}

if (Array.isArray(settings.options)) {
settings.options = settings.options.reduce(
(obj, key) => Object.assign(obj, { [key]: key }),
{}
);
}
// console.log(settings.options)
let options = "";
for (let [key, value] of Object.entries(settings.options)) {
if (key === "null") {
// console.log("null!");
options += `<option ${
key == settings.selected ? "selected" : ""
} value = ${null}></option>`;
} else {
options += `<option ${
key == settings.selected ? "selected" : ""
} value = '${value}'>${key}</option>`;
}

// console.log(key, value);
}
// console.log(options);

settings.value = options;
// settings.additionalElement = {
// name: "caret",
// value: `<path d = 'M0,1.5 6,8.5 12,1.5'>`
// };

return input(settings, "select");
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more