Skip to content

Commit

Permalink
Add local Mantine theme to have tinier components in control drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
vhiribarren committed Jan 21, 2024
1 parent 6a4cceb commit af83978
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/components/shaders/FragmentView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { ActionIcon, Affix, Drawer, Flex, Stack, Text, Title } from "@mantine/core";
import { ActionIcon, Affix, Drawer, Flex, MantineThemeProvider, NumberInput, Select, Slider, Stack, Switch, Text, Title, createTheme } from "@mantine/core";
import FragmentCanvas from "./FragmentCanvas";
import React, { useEffect, useRef, useState } from "react";
import Fragment, { FragmentHandle } from "./Fragment";
Expand Down Expand Up @@ -34,6 +34,33 @@ type Pixels = number;
const DESKTOP_THRESHOLD: Pixels = 680;


const THEME_DRAWER_CONTROL = createTheme({
components: {
NumberInput: NumberInput.extend({
defaultProps: {
size: "xs",
},
}),
Select: Select.extend({
defaultProps: {
size: "xs",
},
}),
Switch: Switch.extend({
defaultProps: {
size: "xs",
},
}),
Slider: Slider.extend({
defaultProps: {
size: "xs",
},
}),
},
});



export function FragmentView({
control, fragmentShader, title, description,
withUi = false, autoRender = false
Expand Down Expand Up @@ -110,7 +137,9 @@ export function FragmentView({
: { target: drawerTargetRef.current as HTMLElement }
}
position={isMobile ? "bottom" : "right"}>
<ui.Out />
<MantineThemeProvider theme={THEME_DRAWER_CONTROL}>
<ui.Out />
</MantineThemeProvider>
</Drawer>
}

Expand Down

0 comments on commit af83978

Please sign in to comment.