diff --git a/.eslintignore b/.eslintignore index 3f5a819d..290c9003 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ workspaces/ -build/ \ No newline at end of file +build/ +apps/ \ No newline at end of file diff --git a/apps/homepage/widget/MetadataEditor.jsx b/apps/homepage/widget/MetadataEditor.jsx new file mode 100644 index 00000000..9f53547c --- /dev/null +++ b/apps/homepage/widget/MetadataEditor.jsx @@ -0,0 +1,204 @@ +const initialMetadata = props.initialMetadata ?? {}; +const onChange = props.onChange; +const options = props.options; + +State.init({ + initialMetadata, + metadata: initialMetadata, + reportedMetadata: initialMetadata, + linktree: initialMetadata.linktree ?? {}, + image: initialMetadata.image, + backgroundImage: initialMetadata.backgroundImage, + screenshots: initialMetadata.screenshots ?? {}, +}); + +const metadata = { + name: options.name ? state.metadata.name : undefined, + description: options.name ? state.metadata.description : undefined, + linktree: + options.linktree && Object.keys(state.linktree).length > 0 + ? state.linktree + : undefined, + image: + options.image && state.image && Object.keys(state.image).length > 0 + ? state.image + : undefined, + backgroundImage: + options.backgroundImage && + state.backgroundImage && + Object.keys(state.backgroundImage).length > 0 + ? state.backgroundImage + : undefined, + tags: options.tags ? state.metadata.tags : undefined, + screenshots: options.screenshots ? state.metadata.screenshots : undefined, +}; + +if ( + onChange && + JSON.stringify(state.reportedMetadata) !== JSON.stringify(metadata) +) { + State.update({ + reportedMetadata: metadata, + }); + onChange(metadata); +} + +const Container = styled.div` + color: #fff; +`; + +const CustomTagEditor = styled.div` + .form-control { + background: #23242b; + border: 1px solid rgba(255, 255, 255, 0.2); + } +`; + +const CustomImageUpload = styled.div` + .nav-link { + background: transparent; + color: #fff; + border: none; + } + + .nav.nav-tabs { + border: none; + } + + .nav-link.active { + color: #fff; + background: transparent; + border: 1px solid rgba(255, 255, 255, 0.2); + border-bottom: none; + } + + .p-2 { + border: none; + border: 1px solid rgba(255, 255, 255, 0.2) !important; + /* border-top: 0; */ + background: #23242b !important; + color: #fff !important; + } + + .form-control { + background: #23242b; + border: 1px solid rgba(255, 255, 255, 0.2); + } +`; + +return ( + + {options.name && ( +
+ + +
+ )} + {options.image && ( +
+ + + State.update({ image }), + }} + /> + +
+ )} + {options.backgroundImage && ( +
+ + State.update({ backgroundImage }), + }} + /> +
+ )} + {options.description && ( +
+ + (supports markdown) +