Skip to content

Commit

Permalink
Move additional modules & components to dium
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed Dec 4, 2023
1 parent 997706b commit 2b64710
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
4 changes: 4 additions & 0 deletions packages/dium/src/components/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {Finder} from "../api";

// chevron small down icon
export const IconArrow = /* @__PURE__ */ Finder.bySource(["d:\"M5.29289 9"], {entries: true});
1 change: 1 addition & 0 deletions packages/dium/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./embed";
export * from "./flex";
export * from "./form";
export * from "./guild";
export * from "./icon";
export * from "./link";
export * from "./margins";
export * from "./menu";
Expand Down
5 changes: 5 additions & 0 deletions packages/dium/src/components/input.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Finder} from "../api";
import {Common} from "./common";

export const enum TextInputSizes {
Expand Down Expand Up @@ -48,3 +49,7 @@ interface InputComponents {
}

export const {TextInput, InputError} = Common as InputComponents;

export const ImageInput: React.ComponentClass<any> = /* @__PURE__ */ Finder.find(
(target) => typeof target.defaultProps?.multiple === "boolean" && typeof target.defaultProps?.maxFileSizeBytes === "number"
);
1 change: 1 addition & 0 deletions packages/dium/src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export * from "./npm";
export * from "./popout-window";
export * from "./router";
export * from "./user";
export * from "./util";

export type Untyped<T> = T & Record<string, any>;
11 changes: 11 additions & 0 deletions packages/dium/src/modules/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {Filters, Finder} from "../api";

export interface AudioConvert {
amplitudeToPerceptual(amplitude: number): number;
perceptualToAmplitude(perceptual: number): number;
}

export const AudioConvert: AudioConvert = /* @__PURE__ */ Finder.demangle({
amplitudeToPerceptual: Filters.bySource("Math.log10"),
perceptualToAmplitude: Filters.bySource("Math.pow(10")
});
8 changes: 2 additions & 6 deletions src/BetterFolders/uploader.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import {Finder, React} from "dium";
import {React} from "dium";
import {GuildsTreeFolder} from "@dium/modules";
import {Flex, Button, FormSwitch, FormText, margins} from "@dium/components";
import {Flex, Button, FormSwitch, FormText, ImageInput, margins} from "@dium/components";
import {FolderData} from "./settings";
import {BetterFolderIcon} from "./icon";

const ImageInput: React.ComponentClass<any> = Finder.find(
(target) => typeof target.defaultProps?.multiple === "boolean" && typeof target.defaultProps?.maxFileSizeBytes === "number"
);

export interface BetterFolderUploaderProps extends FolderData {
folderNode: GuildsTreeFolder;
onChange(data: FolderData): void;
Expand Down
12 changes: 1 addition & 11 deletions src/BetterVolume/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import {createPlugin, Finder, Filters, Patcher, React} from "dium";
import {Snowflake, MediaEngineStore, MediaEngineActions, MediaEngineContext} from "@dium/modules";
import {Snowflake, MediaEngineStore, MediaEngineActions, MediaEngineContext, AudioConvert} from "@dium/modules";
import {MenuItem, FormSwitch} from "@dium/components";
import {Settings} from "./settings";
import {NumberInput} from "./input";
import {handleExperiment, hasExperiment, resetExperiment} from "./experiment";
import {css} from "./styles.module.scss";

interface AudioConvert {
amplitudeToPerceptual(amplitude: number): number;
perceptualToAmplitude(perceptual: number): number;
}

const AudioConvert: AudioConvert = Finder.demangle({
amplitudeToPerceptual: Filters.bySource("Math.log10"),
perceptualToAmplitude: Filters.bySource("Math.pow(10")
});

type UseUserVolumeItem = (userId: Snowflake, context: MediaEngineContext) => JSX.Element;

export default createPlugin({
Expand Down
8 changes: 3 additions & 5 deletions src/CollapseEmbeds/hider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {Finder, React} from "dium";
import {React} from "dium";
import {classNames} from "@dium/modules";
import {Flex, Clickable, Text} from "@dium/components";
import {Flex, Clickable, Text, IconArrow} from "@dium/components";
import {Settings} from "./settings";
import styles from "./styles.module.scss";

const Arrow = Finder.bySource(["d:\"M5.293 9"], {entries: true});

export const enum AccessoryType {
Embed = "embed",
Attachment = "attachment"
Expand Down Expand Up @@ -37,7 +35,7 @@ export const Hider = ({placeholders, type, children}: HiderProps): JSX.Element =
className={styles.hideButton}
onClick={() => setShown(!shown)}
>
<Arrow className={classNames(styles.icon, shown ? styles.open : null)}/>
<IconArrow className={classNames(styles.icon, shown ? styles.open : null)}/>
</Clickable>
</Flex>
);
Expand Down
2 changes: 1 addition & 1 deletion src/CollapseEmbeds/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "CollapseEmbeds",
"author": "Zerthox",
"version": "1.0.4",
"version": "1.0.5",
"description": "Adds a button to collapse embeds & attachments.",
"dependencies": {
"dium": "*"
Expand Down

0 comments on commit 2b64710

Please sign in to comment.