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

Selectively Enable Source Data Interfaces #502

Merged
merged 30 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
14bcabb
Basic visual disabling
garrettmflynn Nov 1, 2023
02abe1e
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 1, 2023
cf00ffd
Force accordion mode
garrettmflynn Nov 1, 2023
796183f
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 1, 2023
b74c14f
Fix validation
garrettmflynn Nov 1, 2023
3c69ea4
Remove info in accordion. Replace with attributes
garrettmflynn Nov 1, 2023
68f533d
Handle disabled properties
garrettmflynn Nov 2, 2023
b352422
Allow globals. Properly update and track disabled accordions
garrettmflynn Nov 3, 2023
2b8f57d
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 3, 2023
c35d039
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 3, 2023
a55a5f7
Better disabling
garrettmflynn Nov 6, 2023
fc269aa
Fix global interaction with instance enable value
garrettmflynn Nov 7, 2023
7ec1689
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 7, 2023
400a190
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 7, 2023
112681e
Merge branch 'main' into disable-schema-props
CodyCBakerPhD Nov 8, 2023
4f5f1db
Track interaction per item
garrettmflynn Nov 8, 2023
a15ffda
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2023
3d5f3a4
Merge branch 'main' into disable-schema-props
CodyCBakerPhD Nov 8, 2023
34abb42
Show status properly on managers
garrettmflynn Nov 8, 2023
65e9e09
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2023
d9a86cf
Fix table tests
garrettmflynn Nov 8, 2023
b62dec6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2023
2fb4730
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 9, 2023
cb6020d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 9, 2023
3bccf88
Update GuidedSourceData.js
garrettmflynn Nov 9, 2023
c492ff5
Require all settings properties
garrettmflynn Nov 9, 2023
5184632
Update SettingsPage.js
garrettmflynn Nov 9, 2023
d28fdc4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 9, 2023
e600a37
Merge branch 'main' into disable-schema-props
garrettmflynn Nov 9, 2023
1a1be17
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion schemas/json/dandi/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
},
"required": ["main_api_key"]
}
}
},
"required": ["api_keys"]
}
140 changes: 88 additions & 52 deletions src/renderer/src/stories/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export class Accordion extends LitElement {
box-sizing: border-box;
}

:host {
display: block;
overflow: hidden;
}

.header {
display: flex;
align-items: end;
Expand Down Expand Up @@ -107,10 +112,14 @@ export class Accordion extends LitElement {
.guided--nav-bar-dropdown::after {
font-size: 0.8em;
position: absolute;
right: 50px;
right: 25px;
font-family: ${unsafeCSS(emojiFontFamily)};
}

.guided--nav-bar-dropdown.toggleable::after {
right: 50px;
}

.guided--nav-bar-dropdown.error::after {
content: "${errorSymbol}";
}
Expand All @@ -123,7 +132,7 @@ export class Accordion extends LitElement {
content: "${successSymbol}";
}

.guided--nav-bar-dropdown:hover {
.guided--nav-bar-dropdown.toggleable:hover {
cursor: pointer;
background-color: lightgray;
}
Expand All @@ -143,34 +152,54 @@ export class Accordion extends LitElement {
padding-left: 0px;
overflow-y: auto;
}

.disabled {
opacity: 0.5;
pointer-events: none;
}
`;
}

static get properties() {
return {
sections: { type: Object, reflect: false },
name: { type: String, reflect: true },
open: { type: Boolean, reflect: true },
disabled: { type: Boolean, reflect: true },
status: { type: String, reflect: true },
};
}

constructor({ sections = {}, contentPadding } = {}) {
constructor({
name,
subtitle,
toggleable = true,
content,
open = false,
status,
disabled = false,
contentPadding,
} = {}) {
super();
this.sections = sections;
this.name = name;
this.subtitle = subtitle;
this.content = content;
this.open = open;
this.status = status;
this.disabled = disabled;
this.toggleable = toggleable;
this.contentPadding = contentPadding;
}

updated() {
Object.entries(this.sections).map(([sectionName, info]) => {
const isActive = info.open;
if (isActive) this.#toggleDropdown(sectionName, true);
else this.#toggleDropdown(sectionName, false);
});
if (!this.content) return;
this.toggle(!!this.open);
}

setSectionStatus = (sectionName, status) => {
const el = this.shadowRoot.querySelector("[data-section-name='" + sectionName + "']");
setStatus = (status) => {
const el = this.shadowRoot.getElementById("dropdown");
el.classList.remove("error", "warning", "valid");
el.classList.add(status);
this.sections[sectionName].status = status;
this.status = status;
};

onClick = () => {}; // Set by the user
Expand All @@ -183,60 +212,67 @@ export class Accordion extends LitElement {
}
};

#toggleDropdown = (sectionName, forcedState) => {
toggle = (forcedState) => {
const hasForce = forcedState !== undefined;
const toggledState = !this.sections[sectionName].open;
const toggledState = !this.open;

let state = hasForce ? forcedState : toggledState;
const desiredState = hasForce ? forcedState : toggledState;
const state = this.toOpen(desiredState);

//remove hidden from child elements with guided--nav-bar-section-page class
const section = this.shadowRoot.querySelector("[data-section='" + sectionName + "']");
const section = this.shadowRoot.getElementById("section");
section.toggleAttribute("hidden", hasForce ? !state : undefined);

const dropdown = this.shadowRoot.querySelector("[data-section-name='" + sectionName + "']");
const dropdown = this.shadowRoot.getElementById("dropdown");
this.#updateClass("active", dropdown, !state);

//toggle the chevron
const chevron = dropdown.querySelector("nwb-chevron");
chevron.direction = state ? "bottom" : "right";
if (chevron) chevron.direction = state ? "bottom" : "right";

this.sections[sectionName].open = state;
if (desiredState === state) this.open = state; // Update state if not overridden
};

toOpen = (state = this.open) => {
if (!this.toggleable) return true; // Force open if not toggleable
else if (this.disabled) return false; // Force closed if disabled
return state;
};

render() {
const isToggleable = this.content && this.toggleable;

return html`
<ul id="guided-nav-items" class="guided--container-nav-items">
${Object.entries(this.sections)
.map(([sectionName, info]) => {
return html`
<div class="guided--nav-bar-section">
<div
class="guided--nav-bar-dropdown ${info.status}"
data-section-name=${sectionName}
@click=${() => this.#toggleDropdown(sectionName, undefined)}
>
<div class="header">
<span>${sectionName}</span>
<small>${info.subtitle}</small>
</div>
${new Chevron({
direction: "right",
color: faColor,
size: faSize,
})}
</div>
<div
data-section="${sectionName}"
class="content hidden"
style="padding: ${this.contentPadding ?? "25px"}"
>
${info.content}
</div>
</div>
`;
})
.flat()}
</ul>
<div class="guided--nav-bar-section">
<div
id="dropdown"
class="guided--nav-bar-dropdown ${isToggleable && "toggleable"} ${this.disabled
? "disabled"
: ""} ${this.status}"
@click=${() => isToggleable && this.toggle()}
>
<div class="header">
<span>${this.name}</span>
<small>${this.subtitle}</small>
</div>
${isToggleable
? new Chevron({
direction: "right",
color: faColor,
size: faSize,
})
: ""}
</div>
${this.content
? html`<div
id="section"
class="content hidden ${this.disabled ? "disabled" : ""}"
style="padding: ${this.contentPadding ?? "25px"}"
>
${this.content}
</div>`
: ""}
</div>
`;
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/renderer/src/stories/InstanceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export class InstanceManager extends LitElement {
#new-info > input {
margin-right: 10px;
}

nwb-accordion {
margin-bottom: 0.5em;
}
`;
}

Expand Down Expand Up @@ -161,7 +165,7 @@ export class InstanceManager extends LitElement {
const id = path.slice(0, i + 1).join("/");
const accordion = this.#accordions[id];
target = target[path[i]]; // Progressively check the deeper nested instances
if (accordion) accordion.setSectionStatus(id, checkStatus(false, false, [...Object.values(target)]));
if (accordion) accordion.setStatus(checkStatus(false, false, [...Object.values(target)]));
}
};

Expand Down Expand Up @@ -299,11 +303,8 @@ export class InstanceManager extends LitElement {
const list = this.#render(value, [...path, key]);

const accordion = new Accordion({
sections: {
[key]: {
content: list,
},
},
name: key,
content: list,
contentPadding: "10px",
});

Expand Down
Loading
Loading