Sha256: 10892c38c9e0e0700ef06af0189efa95a743b5b9455138825b5da3bb20ae80b0
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
/** @jsx jsx */ import { jsx, css } from '@emotion/react' import React, { useState, useEffect, useContext } from "react"; import { ButtonsSettingContext, } from "./../contexts/buttons_setting"; import { Plugin, PluginBody, AvailablePlugins } from "../types/plugin"; import { installMacroType, uninstallMacroType } from "../reducers/layer_reducer"; const macroClassNamespaces = AvailablePlugins.map((v) => { return Object.entries(v).map((v) => { const name = v[0]; const plugin = v[1]; return plugin.macros.map((m) => { return m.class_namespace }) }) }).flat().flat(); type Props = { classNamespace: string; }; export const InstallableMacro = ({ classNamespace }: Props) => { const { layers, layersDispatch } = useContext(ButtonsSettingContext); const isChecked = (name: string) => { return layers.installed_macros[name] || false; } const handleClick = (e: React.ChangeEvent<HTMLInputElement>) => { if(isChecked(classNamespace)) { layersDispatch({ type: uninstallMacroType, payload: { installed_macro: classNamespace }}); } else { layersDispatch({ type: installMacroType, payload: { installed_macro: classNamespace }}); } } return( <> <input type="checkbox" onChange={handleClick} checked={isChecked(classNamespace)} /> {classNamespace} </> ) } export const InstallableMacros = () => { return( <> { macroClassNamespaces.map((classNamespace, i) => { return( <div key={i}> <label> <InstallableMacro classNamespace={classNamespace} /> </label> </div> ); }) } </> ) }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
procon_bypass_man-web-0.1.0 | src/components/installable_macros.tsx |