-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stashapp:main' into main
- Loading branch information
Showing
12 changed files
with
22,475 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
"use strict"; | ||
(function () { | ||
const api = window.PluginApi; | ||
const React = api.React; | ||
const { Button, Modal } = api.libraries.Bootstrap; | ||
const { faNoteSticky } = api.libraries.FontAwesomeSolid; | ||
const NotesComponent = () => { | ||
const storageKey = "Stash Notes"; | ||
const [display, setDisplay] = React.useState(false); | ||
const [notes, setNotes] = React.useState(""); | ||
const enableModal = () => setDisplay(true); | ||
const disableModal = () => setDisplay(false); | ||
const saveNotes = (notes) => { | ||
localStorage.setItem(storageKey, notes); | ||
disableModal(); | ||
}; | ||
React.useEffect(() => { | ||
const notesFromStorage = localStorage.getItem(storageKey); | ||
if (notesFromStorage) { | ||
setNotes(notesFromStorage); | ||
} | ||
}, []); | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.createElement(NavButton, { onClickHandler: enableModal }), | ||
React.createElement(NotesModal, { | ||
displayState: display, | ||
onCloseHandler: disableModal, | ||
onSaveHandler: saveNotes, | ||
notesState: notes, | ||
notesChangeHandler: (n) => setNotes(n), | ||
}) | ||
); | ||
}; | ||
const NavButton = ({ onClickHandler }) => { | ||
const { Icon } = api.components; | ||
return React.createElement( | ||
React.Fragment, | ||
null, | ||
React.createElement( | ||
Button, | ||
{ | ||
className: "nav-utility minimal", | ||
title: "Notes", | ||
onClick: onClickHandler, | ||
}, | ||
React.createElement(Icon, { icon: faNoteSticky }) | ||
) | ||
); | ||
}; | ||
const NotesModal = ({ | ||
displayState, | ||
onCloseHandler, | ||
onSaveHandler, | ||
notesState, | ||
notesChangeHandler, | ||
}) => { | ||
return React.createElement( | ||
Modal, | ||
{ show: displayState, onHide: onCloseHandler }, | ||
React.createElement( | ||
Modal.Header, | ||
{ closeButton: true }, | ||
React.createElement(Modal.Title, null, "Notes") | ||
), | ||
React.createElement( | ||
Modal.Body, | ||
null, | ||
React.createElement("textarea", { | ||
className: "text-input form-control", | ||
rows: 10, | ||
value: notesState, | ||
onChange: (e) => notesChangeHandler(e.target.value), | ||
}), | ||
React.createElement("hr", null), | ||
React.createElement("h5", null, "Important!"), | ||
"Notes are stored as plain text in your browser's local storage. Do not save sensitive information. Notes will be lost after closing a browser in incognito mode." | ||
), | ||
React.createElement( | ||
Modal.Footer, | ||
null, | ||
React.createElement( | ||
Button, | ||
{ variant: "secondary", onClick: onCloseHandler }, | ||
"Close" | ||
), | ||
React.createElement( | ||
Button, | ||
{ variant: "primary", onClick: () => onSaveHandler(notesState) }, | ||
"Save Changes" | ||
) | ||
) | ||
); | ||
}; | ||
api.patch.before("MainNavBar.UtilityItems", function (props) { | ||
return [ | ||
{ | ||
children: React.createElement( | ||
React.Fragment, | ||
null, | ||
props.children, | ||
React.createElement(NotesComponent, null) | ||
), | ||
}, | ||
]; | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
name: Stash Notes | ||
description: Adds a button to the navigation bar which opens a small window for writing notes to your browser's local storage. | ||
version: 1.0 | ||
ui: | ||
javascript: | ||
- stashNotes.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Theme Switch | ||
|
||
## Information about plugin | ||
|
||
Adds a button that shows a menu, allowing you to change CSS Themes and apply various CSS snippets for Stash App. The CSS isn't made by myself and in the CSS files authors where known are referenced. | ||
|
||
Only the CSS of one theme can be applied at a time, and any amount of snippets can be applied. | ||
|
||
Clicking on any radio/checkbox to apply the CSS, saves the CSS content of the Stylesheet in the browsers local storage, with an applied flag, eitehr true or false which allows the script upon page navigation and refresh to apply previously selected stylesheets | ||
|
||
Under Change Order of Menu Bar, you can drag the elements to reorder the main menu and upon dropping it will generate the required CSS. It should work on touchscreens also, tested on Chrome IOS. | ||
|
||
![Theme Plugin 1](https://github.com/elkorol/Stash-App-Theme-Switch-Plugin/blob/193f54fce3914991440027c4b98fd30aa9402d29/images/1.png) | ||
|
||
![Theme Plugin 2](https://github.com/elkorol/Stash-App-Theme-Switch-Plugin/blob/193f54fce3914991440027c4b98fd30aa9402d29/images/2.png) | ||
|
||
## Other Requirements | ||
|
||
## Usage | ||
|
||
1. Copy repository into Stash plugins folder. | ||
2. Reload plugins from settings and enable | ||
|
||
## Credit | ||
|
||
The CSS code used is provided by [Stash Community Themes](https://docs.stashapp.cc/user-interface-ui/themes) and [Stash Community Custom CSS Snippets](https://docs.stashapp.cc/user-interface-ui/custom-css-snippets). | ||
|
||
## Adding your own CSS | ||
|
||
To add your own CSS open the themeSwitchCSS.js file. CSS is defined in const variables. They are ordered in categories. You can make your own categories too. Just define a variable to hold your css and put the css inbetween backticks ``. | ||
|
||
Then look for the variable themeSwitchCSS at the bottom of the file. If adding to an existing category to just add a new number at the end. Or if you are reordering the CSS or themes. Be sure to update the numbering and there is no duplicate numbers within a theme or some won't render. It's stuctured like but can be seen better within the file itself. | ||
|
||
const themeSwitchCSS = { | ||
Theme: { | ||
1: { | ||
displayName: "Default", | ||
styles: null, | ||
key: "themeSwitchPlugin-theme-default", | ||
version: null, | ||
}, | ||
2: { | ||
displayName: "Black Hole", | ||
styles: blackHole, | ||
key: "themeSwitchPlugin-theme-blackHole", | ||
version: "2.0", | ||
} | ||
YourCategoryHere: { | ||
1: { | ||
displayName: "Your CSS Name Here", | ||
styles: Your-CSS-Variable-Name-Here, | ||
key: "themeSwitchPlugin-YourCategoryHere-AnIDforYourCSS", | ||
version: VersionNumberOrNull, | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Theme Switch | ||
description: Theme and CSS script manager located in main menu bar top right. | ||
url: | ||
version: 2.1 | ||
ui: | ||
requires: | ||
- stashUserscriptLibrary | ||
javascript: | ||
- themeSwitchMain.js | ||
- themeSwitchCSS.js | ||
css: | ||
- themeSwtichDefault.css |
Oops, something went wrong.