ui: rewrap @theme-ui's button component (#10063)

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2026-07-08 10:24:08 +05:00
committed by GitHub
parent 108bf75081
commit e636b71ef2
4 changed files with 110 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from "react";
import {
Button as ThemeUIButton,
ButtonProps as ThemeUIButtonProps
} from "@theme-ui/components";
import { Theme } from "@notesnook/theme";
import { RestrictedSpaceProps, RestrictedSxProp } from "../utils/types.js";
export interface ButtonProps
extends Omit<
ThemeUIButtonProps,
"variant" | "sx" | keyof RestrictedSpaceProps
>,
RestrictedSpaceProps {
variant?: keyof Theme["buttons"];
sx?: RestrictedSxProp;
}
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
(props, ref) => {
return <ThemeUIButton ref={ref} {...props} />;
}
);

View File

@@ -21,3 +21,4 @@ export * from "./icon/index.js";
export * from "./menu/index.js";
export * from "./popup-presenter/index.js";
export * from "./scroll-container/index.js";
export * from "./button.js";

View File

@@ -18,3 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from "./position.js";
export * from "./types.js";

View File

@@ -0,0 +1,66 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Theme } from "@notesnook/theme";
import { ThemeUIStyleObject } from "@theme-ui/core";
type ThemeSpace = Theme["space"];
type ValidSpaceValues =
| Exclude<keyof ThemeSpace, keyof Array<any> | "small">
| "small"
| number;
export type RestrictedSpaceProps = {
[K in
| "m"
| "mt"
| "mr"
| "mb"
| "ml"
| "mx"
| "my"
| "margin"
| "marginTop"
| "marginRight"
| "marginBottom"
| "marginLeft"
| "marginX"
| "marginY"
| "p"
| "pt"
| "pr"
| "pb"
| "pl"
| "px"
| "py"
| "padding"
| "paddingTop"
| "paddingRight"
| "paddingBottom"
| "paddingLeft"
| "paddingX"
| "paddingY"]?: ValidSpaceValues | (ValidSpaceValues | null)[];
};
export type RestrictedSxProp = Omit<
ThemeUIStyleObject,
keyof RestrictedSpaceProps
> &
RestrictedSpaceProps;