adithyasource / clear Goto Github PK
View Code? Open in Web Editor NEWsimple and lightweight game launcher
Home Page: https://clear.adithya.zip
License: The Unlicense
simple and lightweight game launcher
Home Page: https://clear.adithya.zip
License: The Unlicense
Is your feature request related to a problem? Please describe.
it's a bit annoying when you import your games from steam and it automatically picks assets without your input, even if you have custom assets already set in steam
Describe the solution you'd like
directly grabbing the assets for imported games from the local steam installation
When navigating using keyboard only in clear
, you can't tell where the focus is.
Every interact-able component (including scrollable lists) should have a :focus
of :focus-visible
style, either the same as :hover
or something obvious (like an outline).
Clickable images (or anything) should be wrapped inside a button, not a div
with onClick
.
In addition, every dynamic component should optimally have WAI-ARIA
roles and signals (or use native elements). This include: modals, toggles (or switch), toasts, buttons, collapsible, context menus.
For these components I'd recommend building on top of https://kobalte.dev. Otherwise the patterns are documented here https://www.w3.org/WAI/ARIA/apg/patterns
Instead of
if (
libraryData().userSettings.roundedBorders == undefined ||
libraryData().userSettings.roundedBorders == true
) {
setRoundedBorders(true);
} else {
setRoundedBorders(false);
}
if (
libraryData().userSettings.gameTitle == undefined ||
libraryData().userSettings.gameTitle == true
) {
setGameTitle(true);
} else {
setGameTitle(false);
}
...
(and also instead of below from #5)
const [showSideBar, setShowSideBar] = createSignal(libraryData().userSettings.showSideBar ?? true);
const [roundedBorders, setRoundedBorders] = createSignal(libraryData().userSettings.roundedBorders ?? true);
...
you can use a store
to manage all your options:
const [libraryData, setLibraryData] = createStore({
userSettings: {
showSideBar: true,
roundedBorders: true,
...
},
...
});
libraryData.userSettings.showSideBar; // => `true`
setLibraryData("userSettings", "showSideBar", false);
A store is like a signal but it works with deeper objects and retains reactivity for nested updates.
This also allows you to load the data straight from the JSON:
const [libraryData, setLibraryData] = createStore(JSON.parse(getLibraryData));
For use inside the context you can either export the store itself:
export function GlobalContextProvider(props) {
const [libraryData, setLibraryData] = createStore(JSON.parse(getLibraryData));
// set defaults
...
const context = {
libraryData,
setLibraryData,
};
return (
<GlobalContext.Provider value={context}>
{props.children}
</GlobalContext.Provider>
);
}
function ExampleComponent() {
const context = useGlobalContext();
context.libraryData.userSettings.showSideBar; // => boolean
context.setLibraryData("userSettings", "showSideBar", false);
}
or you could create derived signals and setters for each:
export function GlobalContextProvider(props) {
const [libraryData, setLibraryData] = createStore(JSON.parse(getLibraryData));
const context = {
showSideBar: () => libraryData.userSettings.showSideBar ?? true, // set defaults here
setShowSideBar: (value) => setLibraryData("userSettings", "showSideBar", value),
};
return (
<GlobalContext.Provider value={context}>
{props.children}
</GlobalContext.Provider>
);
}
function ExampleComponent() {
const context = useGlobalContext();
context.showSideBar(); // => boolean
context.setShowSideBar(true);
}
Solid docs:
https://docs.solidjs.com/concepts/stores
https://docs.solidjs.com/reference/store-utilities/create-store
Checkout #7 for a better storage interface.
Here's a few tricks to make component syntax shorter:
<Show when={selectedGame().favourite}>
<div className="relative">
<div className="!w-max"> {translateText("favourite")}</div>
<div className="absolute blur-[5px] opacity-70 -z-10 inset-0 !w-max">
{translateText("favourite")}
</div>
</div>
</Show>
<Show when={!selectedGame().favourite}>
<div className="!w-max"> {translateText("favourite")}</div>
</Show>
// is equal to
<Show when={selectedGame().favourite} fallback={<div className="!w-max"> {translateText("favourite")}</div>}>
<div className="relative">
<div className="!w-max"> {translateText("favourite")}</div>
<div className="absolute blur-[5px] opacity-70 -z-10 inset-0 !w-max">
{translateText("favourite")}
</div>
</div>
</Show>
https://docs.solidjs.com/reference/components/show
<Show when={editedLocatedGame() === undefined}>
...
</Show>
<Show when={editedLocatedGame() === null}>
...
</Show>
<Show when={editedLocatedGame()}>
...
</Show>
// can be replaced by
<Switch>
<Match when={editedLocatedGame() === undefined}>
...
</Match>
<Match when={editedLocatedGame() === null}>
...
</Match>
<Match when={editedLocatedGame()}>
...
</Match>
</Switch>
// or
<Switch fallback={... /* same as `when={editedLocatedGame()}` */}>
<Match when={editedLocatedGame() === undefined}>
...
</Match>
<Match when={editedLocatedGame() === null}>
...
</Match>
</Switch>
https://docs.solidjs.com/reference/components/switch-and-match
Also in general I'd recommend making smaller components (splitting into multiple functions or files).
And either placing all svg icons in a separate file (example) or an icon library (like solid-icons).
Instead of writing your signals in a file and importing all of them (including setting defaults in App.jsx) create a context and a provider to handle defaults.
Instead of:
// Signals.js
...
export const [showSideBar, setShowSideBar] = createSignal(true);
export const [roundedBorders, setRoundedBorders] = createSignal(true);
export const [gameTitle, setGameTitle] = createSignal(true);
export const [folderTitle, setFolderTitle] = createSignal(true);
export const [quitAfterOpen, setQuitAfterOpen] = createSignal(true);
export const [fontName, setFontName] = createSignal("sans serif");
...
create a context:
// global-context.js
const GlobalContext= createContext();
export function useGlobalContext() {
const context = useContext(GlobalContext);
if (context === undefined) {
throw new Error(
"[clear]: `useGlobalContext` must be used within a `GlobalContextProvider` component",
);
}
return context;
}
export function GlobalContextProvider(props) {
// Handle all defaults here
const [showSideBar, setShowSideBar] = createSignal(libraryData().userSettings.showSideBar ?? true);
const [roundedBorders, setRoundedBorders] = createSignal(libraryData().userSettings.roundedBorders ?? true);
...
// side note:
libraryData().userSettings.showSideBar ?? true
// is a shorthand for:
libraryData().userSettings.showSideBar == undefined
? true
: libraryData().userSettings.showSideBar;
// same for:
libraryData().userSettings.roundedBorders ?? true
// is short for:
if (
libraryData().userSettings.roundedBorders == undefined ||
libraryData().userSettings.roundedBorders == true
) {
true
} else {
false
}
// end of note
const context = {
showSideBar,
setShowSideBar,
...
};
return (
<GlobalContext.Provider value={context}>
{props.children}
</GlobalContext.Provider>
);
}
and in index.jsx
:
render(() => <GlobaContextProvider><App /></GlobaContextProvider>, document.getElementById("root"));
Then in any component you can use:
function ExampleComponent() {
const context = useGlobalContext();
context.showSideBar(); // => boolean
context.setShowSideBar(true);
}
For a concrete example you can checkout these files from Kobalte:
https://github.com/kobaltedev/kobalte/blob/main/packages/core/src/dialog/dialog-context.tsx
https://github.com/kobaltedev/kobalte/blob/main/packages/core/src/dialog/dialog-root.tsx
Solid docs:
https://docs.solidjs.com/concepts/context
https://docs.solidjs.com/reference/component-apis/create-context
Writing a follow up separate issue #6 for better state management using a store.
Also checkout #7 for a better storage interface.
Instead of writing the data to system yourself, you can use @solid-primitives/filesystem
to make a wrapper to tauri fs
.
Once your libraryData
is reactive (i.e. using a store from #6 in a context #5)
await writeTextFile(
{
path: "data.json",
contents: JSON.stringify(libraryData(), null, 4),
},
{
dir: BaseDirectory.AppData,
},
)
// becomes
const tfs = makeTauriFileSystem({dir: BaseDirectory.AppData});
const fs = createFileSystem(tfs);
// This will automatically write the file each time `libraryData` is changed
// Only write this once! This will run whenever the store is updated (from anywhere)
createEffect(() => fs.writeFile("data.json", JSON.stringify(unwrap(libraryData), null, 4)));
Solid docs:
https://docs.solidjs.com/concepts/effects#effects
https://docs.solidjs.com/reference/basic-reactivity/create-effect
https://docs.solidjs.com/concepts/stores#extracting-raw-data-with-unwrap
Solid Primitives docs:
https://primitives.solidjs.community/package/filesystem
How do you launch games from Steam in the format steam://rungameid/105600 I searched but didn’t really understand how it was implemented
This is a complete Russian translation.
I had to change the permission to txt so that github would let it through.
I used the latest version from github.
This is a modified file - Text.txt
Is your feature request related to a problem? Please describe.
would be pretty neat if when you hovered over a game it showed dlc art or an alternate cover, (would maybe have to mark a game as has playable dlc considering some games only have cosmetic dlc) or other games with the same name, allowing multiple platforms' versions to be availiable in clear at once, instead of needing to add several and look through the library to find all of them if you sort your library by platform.
Describe the solution you'd like
this would preferably be togglable but wouldn't be bad if it wasn't
Additional context
mouse off (dlc)
mouse on (dlc)
mouse off (platforms)
mouse on (platforms)
also sorry if I came off as narcissistic or entitled or anything
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.