mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-07-09 20:09:36 +02:00
ui: rewrap @theme-ui's button component (#10063)
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
42
packages/ui/src/components/button.tsx
Normal file
42
packages/ui/src/components/button.tsx
Normal 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} />;
|
||||
}
|
||||
);
|
||||
@@ -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";
|
||||
|
||||
@@ -18,3 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from "./position.js";
|
||||
export * from "./types.js";
|
||||
|
||||
66
packages/ui/src/utils/types.ts
Normal file
66
packages/ui/src/utils/types.ts
Normal 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;
|
||||
Reference in New Issue
Block a user