Skip to content

Commit

Permalink
Merge branch 'main' into remove-capsules
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored May 17, 2024
2 parents 71cad48 + c93164b commit 31b47b0
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
33 changes: 33 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Improve spacing */
.version-switcher__container.dropdown {
margin-left: 10px;
}

button.btn.version-switcher__button {
margin-bottom: 0px;
}

/* Show on hover */
.version-switcher__container.dropdown:hover .dropdown-menu {
display: block;
left: 0;
margin-top: var(--bs-dropdown-spacer);
top: 100%;
}

.dropdown-menu.show {
display: none;
}

/* Remove underline and borders */
button.btn.version-switcher__button:hover {
text-decoration: none;
}

.version-switcher__menu a.list-group-item {
border: none !important;
}

.version-switcher__menu a.list-group-item:hover {
text-decoration: none !important;
}
10 changes: 7 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
]

# These paths are either relative to html_static_path or fully qualified paths (eg. https://...)
# html_css_files = [
# "css/custom.css",
# ]
html_css_files = [
"css/custom.css",
]

linkcheck_anchors = False

Expand Down Expand Up @@ -85,6 +85,7 @@
version_match = os.environ.get("READTHEDOCS_VERSION")
with open("../package.json") as f:
release = json.load(f)["version"]

# If READTHEDOCS_VERSION doesn't exist, we're not on RTD
# If it is an integer, we're in a PR build and the version isn't correct.
# If it's "latest" → change to "dev" (that's what we want the switcher to call it)
Expand Down Expand Up @@ -144,3 +145,6 @@ def _correct_signatures(app, what, name, obj, options, signature, return_annotat

def setup(app): # This makes the data-interfaces signatures display on the docs/api, they don't otherwise
app.connect("autodoc-process-signature", _correct_signatures)

# Add custom CSS
app.add_css_file("css/custom.css")
6 changes: 6 additions & 0 deletions schemas/source-data.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function preprocessSourceDataSchema (schema) {

const info = interfaces[key] ?? {}

const files = schema.properties.file_paths ?? schema.properties.file_path
const singleLocationInfo = schema.properties.file_path ?? schema.properties.folder_path

if (schema.properties.file_paths) {
Expand All @@ -29,6 +30,11 @@ export default function preprocessSourceDataSchema (schema) {

}

if (files) {
const base = singleLocationInfo ? files : files.items
if (!base.accept && info.suffixes) base.accept = info.suffixes
}

// Do not show steps
if (schema.properties.gain) schema.properties.gain.step = null

Expand Down
20 changes: 17 additions & 3 deletions src/renderer/src/stories/FileSystemSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export class FilesystemSelector extends LitElement {
if (props.onSelect) this.onSelect = props.onSelect;
if (props.onChange) this.onChange = props.onChange;
if (props.onThrow) this.onThrow = props.onThrow;

this.accept = props.accept;
this.multiple = props.multiple;
this.type = props.type ?? "file";
this.value = props.value ?? "";
Expand All @@ -125,6 +127,17 @@ export class FilesystemSelector extends LitElement {

#useElectronDialog = async (type) => {
const options = { ...this.dialogOptions };

if (!options.filters && this.accept) {
options.filters = [
{
name: "Suggested Files",
extensions: this.accept.map((ext) => (ext[0] === "." ? ext.slice(1) : ext)),
},
{ name: "All Files", extensions: ["*"] },
];
}

options.properties = [
type === "file" ? "openFile" : "openDirectory",
"noResolveAliases",
Expand All @@ -142,7 +155,8 @@ export class FilesystemSelector extends LitElement {
return result;
};

#checkType = (value) => {
#check = (value) => {
// Check type
const isLikelyFile = fs ? fs.statSync(value).isFile() : value.split(".").length;
if ((this.type === "directory" && isLikelyFile) || (this.type === "file" && !isLikelyFile))
this.#onThrow("Incorrect filesystem object", `Please provide a <b>${this.type}</b> instead.`);
Expand All @@ -152,8 +166,8 @@ export class FilesystemSelector extends LitElement {
const resolvedType = type ?? this.type;

if (pathOrPaths) {
if (Array.isArray(pathOrPaths)) pathOrPaths.forEach(this.#checkType);
else if (!type) this.#checkType(pathOrPaths);
if (Array.isArray(pathOrPaths)) pathOrPaths.forEach(this.#check);
else if (!type) this.#check(pathOrPaths);
}

let resolvedValue = pathOrPaths;
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/stories/JSONSchemaInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ export class JSONSchemaInput extends LitElement {
const filesystemSelectorElement = new FilesystemSelector({
type: format,
value: this.value,
accept: schema.accept,
onSelect: (paths = []) => {
const value = paths.length ? paths : undefined;
this.#updateData(fullPath, value);
Expand Down

0 comments on commit 31b47b0

Please sign in to comment.