Browse Source

Update components

Expose classname for extending components.
master
TheoryOfNekomata 1 year ago
parent
commit
e4a544fd0f
12 changed files with 106 additions and 22 deletions
  1. +1
    -1
      packages/base/package.json
  2. +3
    -1
      packages/base/src/common.ts
  3. +1
    -1
      packages/base/src/plugin-tailwind.ts
  4. +1
    -1
      packages/react/package.json
  5. +9
    -1
      packages/react/src/layouts/Basic/index.tsx
  6. +18
    -3
      packages/react/src/layouts/LeftSidebar/index.tsx
  7. +38
    -7
      packages/react/src/layouts/LeftSidebarWithMenu/index.tsx
  8. +18
    -3
      packages/react/src/layouts/RightSidebarStatic/index.tsx
  9. +2
    -0
      packages/react/src/widgets/LeftSidebarBase/index.tsx
  10. +6
    -2
      packages/react/src/widgets/LeftSidebarWithMenuBase/index.tsx
  11. +7
    -2
      packages/react/src/widgets/RightSidebarBase/index.tsx
  12. +2
    -0
      packages/react/src/widgets/TopBar/index.tsx

+ 1
- 1
packages/base/package.json View File

@@ -1,6 +1,6 @@
{ {
"name": "@tesseract-design/viewfinder-base", "name": "@tesseract-design/viewfinder-base",
"version": "0.0.0",
"version": "0.0.1",
"files": [ "files": [
"dist", "dist",
"src" "src"


+ 3
- 1
packages/base/src/common.ts View File

@@ -1 +1,3 @@
export type Span = 'narrow' | 'normal' | 'wide';
export const AVAILABLE_SPANS = ['narrow', 'normal', 'wide'] as const;

export type Span = typeof AVAILABLE_SPANS[number];

+ 1
- 1
packages/base/src/plugin-tailwind.ts View File

@@ -9,7 +9,7 @@ export interface ViewfinderPluginOptions {
colorSidebarMenu?: string; colorSidebarMenu?: string;
} }


export const plugin = tailwindPlugin.withOptions<ViewfinderPluginOptions>(
export const plugin = tailwindPlugin.withOptions<ViewfinderPluginOptions | undefined>(
({ ({
baseWidth = 360 as const, baseWidth = 360 as const,
topbarHeight = '4rem' as const, topbarHeight = '4rem' as const,


+ 1
- 1
packages/react/package.json View File

@@ -1,6 +1,6 @@
{ {
"name": "@tesseract-design/viewfinder-react", "name": "@tesseract-design/viewfinder-react",
"version": "0.0.0",
"version": "0.0.1",
"files": [ "files": [
"dist", "dist",
"src" "src"


+ 9
- 1
packages/react/src/layouts/Basic/index.tsx View File

@@ -9,6 +9,7 @@ export interface RootProps extends React.HTMLProps<HTMLDivElement> {
export const Root = React.forwardRef<HTMLDivElement, RootProps>(({ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
children, children,
topBarWidget, topBarWidget,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<> <>
@@ -16,7 +17,10 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
<div <div
{...etcProps} {...etcProps}
data-viewfinder="main" data-viewfinder="main"
className="box-border"
className={clsx(
'box-border',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -33,14 +37,18 @@ export type ContentContainerProps = Omit<React.HTMLProps<HTMLDivElement>, 'span'
export const ContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({ export const ContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({
children, children,
span = 'normal', span = 'normal',
className,
...etcProps
}, ref) => { }, ref) => {
return ( return (
<div <div
{...etcProps}
className={clsx( className={clsx(
'px-8 box-border mx-auto w-full', 'px-8 box-border mx-auto w-full',
span === 'narrow' && 'max-w-screen-2xs', span === 'narrow' && 'max-w-screen-2xs',
span === 'normal' && 'max-w-screen-xs', span === 'normal' && 'max-w-screen-xs',
span === 'wide' && 'max-w-screen-sm', span === 'wide' && 'max-w-screen-sm',
className,
)} )}
ref={ref} ref={ref}
> >


+ 18
- 3
packages/react/src/layouts/LeftSidebar/index.tsx View File

@@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import clsx from 'clsx';


export interface RootProps extends React.HTMLProps<HTMLDivElement> { export interface RootProps extends React.HTMLProps<HTMLDivElement> {
sidebarBaseWidget?: React.ReactNode; sidebarBaseWidget?: React.ReactNode;
@@ -9,6 +10,7 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
children, children,
topBarWidget, topBarWidget,
sidebarBaseWidget, sidebarBaseWidget,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<> <>
@@ -18,7 +20,10 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
{...etcProps} {...etcProps}
ref={ref} ref={ref}
data-viewfinder="main" data-viewfinder="main"
className="box-border md:pl-[calc(50%-(var(--base-width)*0.5))]"
className={clsx(
'box-border md:pl-[calc(50%-(var(--base-width)*0.5))]',
className,
)}
> >
{children} {children}
</div> </div>
@@ -29,9 +34,15 @@ export interface ContentContainerProps extends React.HTMLProps<HTMLDivElement> {


export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({ export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({
children, children,
className,
...etcProps
}, ref) => ( }, ref) => (
<div <div
className="px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0"
{...etcProps}
className={clsx(
'px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -44,11 +55,15 @@ export interface SidebarMainContainerProps extends React.HTMLProps<HTMLDivElemen


export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({ export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<div <div
{...etcProps} {...etcProps}
className="w-full mx-auto px-8 box-border max-w-[calc(var(--base-width)*2)] md:w-[var(--base-width)] md:mr-0"
className={clsx(
'w-full mx-auto px-8 box-border max-w-[calc(var(--base-width)*2)] md:w-[var(--base-width)] md:mr-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}


+ 38
- 7
packages/react/src/layouts/LeftSidebarWithMenu/index.tsx View File

@@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import clsx from 'clsx';


export interface RootProps extends React.HTMLProps<HTMLDivElement> { export interface RootProps extends React.HTMLProps<HTMLDivElement> {
sidebarBaseWidget?: React.ReactNode; sidebarBaseWidget?: React.ReactNode;
@@ -9,6 +10,7 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
children, children,
topBarWidget, topBarWidget,
sidebarBaseWidget, sidebarBaseWidget,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<> <>
@@ -18,7 +20,10 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
{...etcProps} {...etcProps}
ref={ref} ref={ref}
data-viewfinder="main" data-viewfinder="main"
className="box-border pb-menu md:pb-0 md:pl-[calc(50%-(var(--base-width)*0.5))]"
className={clsx(
'box-border pb-menu md:pb-0 md:pl-[calc(50%-(var(--base-width)*0.5))]',
className,
)}
> >
{children} {children}
</div> </div>
@@ -29,9 +34,15 @@ export interface ContentContainerProps extends React.HTMLProps<HTMLDivElement> {


export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({ export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({
children, children,
className,
...etcProps
}, ref) => ( }, ref) => (
<div <div
className="px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0"
{...etcProps}
className={clsx(
'px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -44,11 +55,15 @@ export interface SidebarMainContainerProps extends React.HTMLProps<HTMLDivElemen


export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({ export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<div <div
{...etcProps} {...etcProps}
className="px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:max-w-none"
className={clsx(
'px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:max-w-none',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -61,11 +76,15 @@ export interface SidebarMenuItemIconProps extends React.HTMLProps<HTMLSpanElemen


export const SidebarMenuItemIcon = React.forwardRef<HTMLSpanElement, SidebarMenuItemIconProps>(({ export const SidebarMenuItemIcon = React.forwardRef<HTMLSpanElement, SidebarMenuItemIconProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<span <span
{...etcProps} {...etcProps}
className="block md:w-menu md:h-menu md:flex md:justify-center md:items-center"
className={clsx(
'block md:w-menu md:h-menu md:flex md:justify-center md:items-center',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -76,11 +95,15 @@ SidebarMenuItemIcon.displayName = 'SidebarMenuItemIcon';


export const SidebarMenuContainer = React.forwardRef<HTMLSpanElement, SidebarMainContainerProps>(({ export const SidebarMenuContainer = React.forwardRef<HTMLSpanElement, SidebarMainContainerProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<span <span
{...etcProps} {...etcProps}
className="box-border flex flex-col justify-center items-center w-full text-center md:justify-start md:ml-auto md:text-left md:w-[var(--base-width)] md:flex-row"
className={clsx(
'box-border flex flex-col justify-center items-center w-full text-center md:justify-start md:ml-auto md:text-left md:w-[var(--base-width)] md:flex-row',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -92,11 +115,15 @@ SidebarMenuContainer.displayName = 'SidebarMenuContainer';


export const MoreSidebarMenuItemIcon = React.forwardRef<HTMLSpanElement, SidebarMenuItemIconProps>(({ export const MoreSidebarMenuItemIcon = React.forwardRef<HTMLSpanElement, SidebarMenuItemIconProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<span <span
{...etcProps} {...etcProps}
className="block mr-4 md:w-menu md:h-menu md:flex md:justify-center md:items-center md:mr-0"
className={clsx(
'block mr-4 md:w-menu md:h-menu md:flex md:justify-center md:items-center md:mr-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -107,11 +134,15 @@ MoreSidebarMenuItemIcon.displayName = 'MoreSidebarMenuItemIcon';


export const MoreSidebarMenuContainer = React.forwardRef<HTMLSpanElement, SidebarMainContainerProps>(({ export const MoreSidebarMenuContainer = React.forwardRef<HTMLSpanElement, SidebarMainContainerProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<span <span
{...etcProps} {...etcProps}
className="flex justify-start items-center w-[calc(var(--base-width)*2)] mx-auto px-8 text-left box-border md:mr-0 md:w-[var(--base-width)] md:pl-0"
className={clsx(
'flex justify-start items-center w-[calc(var(--base-width)*2)] mx-auto px-8 text-left box-border md:mr-0 md:w-[var(--base-width)] md:pl-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}


+ 18
- 3
packages/react/src/layouts/RightSidebarStatic/index.tsx View File

@@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import clsx from 'clsx';


export interface RootProps extends React.HTMLProps<HTMLDivElement> { export interface RootProps extends React.HTMLProps<HTMLDivElement> {
sidebarBaseWidget?: React.ReactNode; sidebarBaseWidget?: React.ReactNode;
@@ -9,6 +10,7 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
children, children,
topBarWidget, topBarWidget,
sidebarBaseWidget, sidebarBaseWidget,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<> <>
@@ -17,7 +19,10 @@ export const Root = React.forwardRef<HTMLDivElement, RootProps>(({
{...etcProps} {...etcProps}
ref={ref} ref={ref}
data-viewfinder="main" data-viewfinder="main"
className="box-border md:pr-[calc(50%-(var(--base-width)*0.5))]"
className={clsx(
'box-border md:pr-[calc(50%-(var(--base-width)*0.5))]',
className,
)}
> >
{children} {children}
</div> </div>
@@ -32,9 +37,15 @@ export interface ContentContainerProps extends React.HTMLProps<HTMLDivElement> {


export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({ export const MainContentContainer = React.forwardRef<HTMLDivElement, ContentContainerProps>(({
children, children,
className,
...etcProps
}, ref) => ( }, ref) => (
<div <div
className="px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:mr-0"
{...etcProps}
className={clsx(
'px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:mr-0',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}
@@ -47,11 +58,15 @@ export interface SidebarMainContainerProps extends React.HTMLProps<HTMLDivElemen


export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({ export const SidebarContentContainer = React.forwardRef<HTMLDivElement, SidebarMainContainerProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<div <div
{...etcProps} {...etcProps}
className="px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0 md:w-[var(--base-width)]"
className={clsx(
'px-8 box-border w-full max-w-[calc(var(--base-width)*2)] mx-auto md:ml-0 md:w-[var(--base-width)]',
className,
)}
ref={ref} ref={ref}
> >
{children} {children}


+ 2
- 0
packages/react/src/widgets/LeftSidebarBase/index.tsx View File

@@ -6,6 +6,7 @@ export interface LeftSidebarBaseProps extends React.HTMLProps<HTMLDivElement> {}
export const LeftSidebarBase = React.forwardRef<HTMLDivElement, LeftSidebarBaseProps>(({ export const LeftSidebarBase = React.forwardRef<HTMLDivElement, LeftSidebarBaseProps>(({
children, children,
open = false, open = false,
className,
...etcProps ...etcProps
}, ref) => { }, ref) => {
return ( return (
@@ -13,6 +14,7 @@ export const LeftSidebarBase = React.forwardRef<HTMLDivElement, LeftSidebarBaseP
className={clsx( className={clsx(
'box-border fixed top-0 -left-full w-full h-full bg-sidebar md:left-0 md:w-[calc(50%-(var(--base-width)*0.5))] scrollbar-hidden', 'box-border fixed top-0 -left-full w-full h-full bg-sidebar md:left-0 md:w-[calc(50%-(var(--base-width)*0.5))] scrollbar-hidden',
open && 'left-0', open && 'left-0',
className,
)} )}
{...etcProps} {...etcProps}
ref={ref} ref={ref}


+ 6
- 2
packages/react/src/widgets/LeftSidebarWithMenuBase/index.tsx View File

@@ -34,6 +34,7 @@ export const LeftSidebarWithMenuBase = React.forwardRef<HTMLDivElement, LeftSide
moreLinkComponent: MoreLinkComponent = LinkComponent, moreLinkComponent: MoreLinkComponent = LinkComponent,
moreLinkItem, moreLinkItem,
moreItemsOpen = false, moreItemsOpen = false,
className,
...etcProps ...etcProps
}, ref) => { }, ref) => {
const primarySidebarMenuItems = sidebarMenuItems.filter(s => !s.secondary) const primarySidebarMenuItems = sidebarMenuItems.filter(s => !s.secondary)
@@ -58,8 +59,11 @@ export const LeftSidebarWithMenuBase = React.forwardRef<HTMLDivElement, LeftSide


return ( return (
<div <div
className="left-sidebar-with-menu-base box-border overflow-hidden contents left-[calc(var(--base-width)*-1)] md:fixed md:top-0 md:left-0 md:w-[calc(50%-var(--base-width)*0.5)] md:h-full md:block"
{...etcProps}
{...etcProps}
className={clsx(
'left-sidebar-with-menu-base box-border overflow-hidden contents left-[calc(var(--base-width)*-1)] md:fixed md:top-0 md:left-0 md:w-[calc(50%-var(--base-width)*0.5)] md:h-full md:block',
className,
)}
ref={ref} ref={ref}
> >
<div <div


+ 7
- 2
packages/react/src/widgets/RightSidebarBase/index.tsx View File

@@ -1,14 +1,19 @@
import * as React from 'react'; import * as React from 'react';
import clsx from 'clsx';


export interface RightSidebarStaticBaseProps extends React.HTMLProps<HTMLDivElement> {} export interface RightSidebarStaticBaseProps extends React.HTMLProps<HTMLDivElement> {}


export const RightSidebarStaticBase = React.forwardRef<HTMLDivElement, RightSidebarStaticBaseProps>(({ export const RightSidebarStaticBase = React.forwardRef<HTMLDivElement, RightSidebarStaticBaseProps>(({
children, children,
className,
...etcProps ...etcProps
}, ref) => ( }, ref) => (
<div <div
className="box-border after:pb-[1px] after:-mt-[1px] after:box-border md:pr-[calc(50%-(var(--base-width)*0.5)] md:absolute md:top-0 md:right-0 md:h-full md:w-[calc(50%-(var(--base-width)*0.5))]"
{...etcProps}
{...etcProps}
className={clsx(
'box-border after:pb-[1px] after:-mt-[1px] after:box-border md:pr-[calc(50%-(var(--base-width)*0.5)] md:absolute md:top-0 md:right-0 md:h-full md:w-[calc(50%-(var(--base-width)*0.5))]',
className,
)}
ref={ref} ref={ref}
> >
<div <div


+ 2
- 0
packages/react/src/widgets/TopBar/index.tsx View File

@@ -15,11 +15,13 @@ export const TopBar = React.forwardRef<HTMLDivElement, TopBarProps>(({
menuLink, menuLink,
userLink, userLink,
children, children,
className,
...etcProps ...etcProps
}, ref) => { }, ref) => {
return ( return (
<div className={clsx( <div className={clsx(
'fixed top-0 left-0 w-full z-[3] topbar', 'fixed top-0 left-0 w-full z-[3] topbar',
className,
)}> )}>
<div <div
{...etcProps} {...etcProps}


Loading…
Cancel
Save