add class names to PluginCard for theming

This commit is contained in:
AAGaming
2022-08-17 15:27:22 -04:00
parent 8d065eab1f
commit 5960c11d60
+20 -11
View File
@@ -6,6 +6,7 @@ import {
Router, Router,
SingleDropdownOption, SingleDropdownOption,
SuspensefulImage, SuspensefulImage,
joinClassNames,
staticClasses, staticClasses,
} from 'decky-frontend-lib'; } from 'decky-frontend-lib';
import { FC, useRef, useState } from 'react'; import { FC, useRef, useState } from 'react';
@@ -22,10 +23,6 @@ interface PluginCardProps {
plugin: StorePlugin | LegacyStorePlugin; plugin: StorePlugin | LegacyStorePlugin;
} }
const classNames = (...classes: string[]) => {
return classes.join(' ');
};
function isLegacyPlugin(plugin: LegacyStorePlugin | StorePlugin): plugin is LegacyStorePlugin { function isLegacyPlugin(plugin: LegacyStorePlugin | StorePlugin): plugin is LegacyStorePlugin {
return 'artifact' in plugin; return 'artifact' in plugin;
} }
@@ -44,7 +41,7 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
> >
{/* TODO: abstract this messy focus hackiness into a custom component in lib */} {/* TODO: abstract this messy focus hackiness into a custom component in lib */}
<Focusable <Focusable
// className="Panel Focusable" className="deckyStoreCard"
ref={containerRef} ref={containerRef}
onActivate={(_: CustomEvent) => { onActivate={(_: CustomEvent) => {
buttonRef.current!.focus(); buttonRef.current!.focus();
@@ -68,15 +65,17 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
boxSizing: 'border-box', boxSizing: 'border-box',
}} }}
> >
<div style={{ display: 'flex', alignItems: 'center' }}> <div className="deckyStoreCardHeader" style={{ display: 'flex', alignItems: 'center' }}>
<a <a
style={{ fontSize: '18pt', padding: '10px' }} style={{ fontSize: '18pt', padding: '10px' }}
className={classNames(staticClasses.Text)} className={joinClassNames(staticClasses.Text)}
// onClick={() => Router.NavigateToExternalWeb('https://github.com/' + plugin.artifact)} // onClick={() => Router.NavigateToExternalWeb('https://github.com/' + plugin.artifact)}
> >
{isLegacyPlugin(plugin) ? ( {isLegacyPlugin(plugin) ? (
<div> <div className="deckyStoreCardNameContainer">
<span style={{ color: 'grey' }}>{plugin.artifact.split('/')[0]}/</span> <span className="deckyStoreCardLegacyRepoOwner" style={{ color: 'grey' }}>
{plugin.artifact.split('/')[0]}/
</span>
{plugin.artifact.split('/')[1]} {plugin.artifact.split('/')[1]}
</div> </div>
) : ( ) : (
@@ -89,8 +88,10 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
}} }}
className="deckyStoreCardBody"
> >
<SuspensefulImage <SuspensefulImage
className="deckyStoreCardImage"
suspenseWidth="256px" suspenseWidth="256px"
style={{ style={{
width: 'auto', width: 'auto',
@@ -113,14 +114,16 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}} }}
className="deckyStoreCardInfo"
> >
<p className={classNames(staticClasses.PanelSectionRow)}> <p className={joinClassNames(staticClasses.PanelSectionRow)}>
<span>Author: {plugin.author}</span> <span>Author: {plugin.author}</span>
</p> </p>
<p className={classNames(staticClasses.PanelSectionRow)}> <p className={joinClassNames('deckyStoreCardTagsContainer', staticClasses.PanelSectionRow)}>
<span>Tags:</span> <span>Tags:</span>
{plugin.tags.map((tag: string) => ( {plugin.tags.map((tag: string) => (
<span <span
className="deckyStoreCardTag"
style={{ style={{
padding: '5px', padding: '5px',
marginRight: '10px', marginRight: '10px',
@@ -133,6 +136,7 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
))} ))}
{isLegacyPlugin(plugin) && ( {isLegacyPlugin(plugin) && (
<span <span
className="deckyStoreCardTag deckyStoreCardLegacyTag"
style={{ style={{
color: '#232120', color: '#232120',
padding: '5px', padding: '5px',
@@ -148,6 +152,7 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
</div> </div>
</div> </div>
<div <div
className="deckyStoreCardActionsContainer"
style={{ style={{
width: '100%', width: '100%',
alignSelf: 'flex-end', alignSelf: 'flex-end',
@@ -156,6 +161,7 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
}} }}
> >
<Focusable <Focusable
className="deckyStoreCardActions"
style={{ style={{
display: 'flex', display: 'flex',
flexDirection: 'row', flexDirection: 'row',
@@ -163,11 +169,13 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
}} }}
> >
<div <div
className="deckyStoreCardInstallButtonContainer"
style={{ style={{
flex: '1', flex: '1',
}} }}
> >
<DialogButton <DialogButton
className="deckyStoreCardInstallButton"
ref={buttonRef} ref={buttonRef}
onClick={() => onClick={() =>
isLegacyPlugin(plugin) isLegacyPlugin(plugin)
@@ -179,6 +187,7 @@ const PluginCard: FC<PluginCardProps> = ({ plugin }) => {
</DialogButton> </DialogButton>
</div> </div>
<div <div
className="deckyStoreCardVersionDropdownContainer"
style={{ style={{
flex: '0.2', flex: '0.2',
}} }}