Skip to content

Commit

Permalink
Test drive themes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewjordan committed Jul 8, 2024
1 parent 76f4d77 commit 383ccfd
Show file tree
Hide file tree
Showing 27 changed files with 766 additions and 304 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/themes": "^3.0.2",
"@stitches/react": "^1.2.8",
"flexsearch": "^0.7.43",
"hls.js": "^1.5.3",
Expand Down
7 changes: 6 additions & 1 deletion pages/docs/image.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ A UI component that renders a _pan and deep-zoom_ Image viewer using [OpenSeadra

<IIIFBadge href="https://iiif.io/api/image/3.0" text={["Image"]} />

<div style={{ height: "38.2vh", minHeight: "450px" }}>
<div
style={{
height: "38.2vh",
minHeight: "450px",
}}
>
<CloverImage
body={{
id: "https://iiif.dc.library.northwestern.edu/iiif/2/6ca016c5-de7f-4373-ae8f-7047fecf6ace/full/600,/0/default.jpg",
Expand Down
516 changes: 516 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

47 changes: 8 additions & 39 deletions src/components/Image/Controls/Button.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,18 @@
import { IconButton } from "@radix-ui/themes";
import { styled } from "src/styles/stitches.config";

const Item = styled("button", {
display: "flex",
height: "2rem",
width: "2rem",
borderRadius: "2rem",
padding: "0",
margin: "0",
fontFamily: "inherit",
background: "none",
backgroundColor: "$primary",
border: "none",
color: "white",
const Item = styled(IconButton, {
cursor: "pointer",
marginLeft: "0.618rem",
filter: "drop-shadow(2px 2px 5px #0003)",
transition: "$all",
boxSizing: "content-box !important",

"&:first-child": {
marginLeft: "0",
},

"@xs": {
marginBottom: "0.618rem",
marginLeft: "0",

"&:last-child": {
marginBottom: "0",
},
},
alignContent: "center",
display: "inline-flex !important",

svg: {
color: "currentColor",
fill: "currentColor",
stroke: "currentColor",
transition: "$all",
height: "60%",
width: "60%",
padding: "20%",
fill: "$secondary",
stroke: "$secondary",
filter: "drop-shadow(2px 2px 5px #0003)",
transition: "$all",
boxSizing: "inherit",
},

"&:hover, &:focus": {
backgroundColor: "$accent",
},

"&[data-button=rotate-right]": {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Image/Controls/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const Button: React.FC<ButtonProps> = ({ className, id, label, children }) => {
className={className}
data-testid="openseadragon-button"
data-button={dataButton}
size="2"
>
<svg
xmlns="http://www.w3.org/2000/svg"
aria-labelledby={`${id}-svg-title`}
data-testid="openseadragon-button-svg"
focusable="false"
viewBox="0 0 512 512"
role="img"
>
<title id={`${id}-svg-title`}>{label}</title>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Image/Controls/Controls.styled.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Flex } from "@radix-ui/themes";
import { styled } from "src/styles/stitches.config";

const Wrapper = styled("div", {
const Wrapper = styled(Flex, {
position: "absolute",
zIndex: "1",
top: "1rem",
right: "1rem",
display: "flex",

"@xs": {
flexDirection: "column",
Expand Down
1 change: 1 addition & 0 deletions src/components/Image/Controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const Controls = ({
<Wrapper
data-testid="clover-iiif-image-openseadragon-controls"
hasPlaceholder={_cloverViewerHasPlaceholder}
gap="2"
>
{config.showZoomControl && (
<>
Expand Down
13 changes: 5 additions & 8 deletions src/components/Image/Image.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ const Navigator = styled("div", {
width: "161.8px",
height: "100px",
backgroundColor: "#000D",
boxShadow: "5px 5px 5px #0002",
borderRadius: "3px",
boxShadow: "var(--shadow-3)",

".displayregion": {
border: " 3px solid $accent !important",
boxShadow: "0 0 3px #0006",
border: " 2px solid var(--accent-10) !important",
boxShadow: "var(--shadow-3)",
},

"@sm": {
Expand All @@ -28,16 +27,14 @@ const Navigator = styled("div", {
});

const Viewport = styled("div", {
position: "relative",
position: "absolute",
width: "100%",
height: "100%",
zIndex: "0",
});

const Wrapper = styled("div", {
width: "100%",
height: "100%",
maxHeight: "100vh",
objectFit: "cover",
background: "transparent",
backgroundSize: "contain",
color: "white",
Expand Down
23 changes: 14 additions & 9 deletions src/components/Image/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "@radix-ui/themes/styles.css";

import { parseImageBody, parseSrc } from "src/lib/openseadragon-helpers";

import { ErrorBoundary } from "react-error-boundary";
Expand All @@ -7,6 +9,7 @@ import { LabeledIIIFExternalWebResource } from "src/types/presentation-3";
import OSD from "src/components/Image/OSD/OSD";
import { Options } from "openseadragon";
import React from "react";
import { Theme } from "@radix-ui/themes";
import defaultOpenSeadragonConfig from "src/components/Image/OSD/defaults";
import { getLabelAsString } from "src/lib/label-helpers";
import { v4 as uuidv4 } from "uuid";
Expand Down Expand Up @@ -47,15 +50,17 @@ const CloverImage: React.FC<CloverImageProps> = ({

return (
<ErrorBoundary FallbackComponent={ErrorFallback}>
<OSD
_cloverViewerHasPlaceholder={_cloverViewerHasPlaceholder}
ariaLabel={ariaLabel}
config={config}
imageType={imageType}
key={instance}
uri={uri}
openSeadragonCallback={openSeadragonCallback}
/>
<Theme style={{ width: "100%", height: "100% !important" }}>
<OSD
_cloverViewerHasPlaceholder={_cloverViewerHasPlaceholder}
ariaLabel={ariaLabel}
config={config}
imageType={imageType}
key={instance}
uri={uri}
openSeadragonCallback={openSeadragonCallback}
/>
</Theme>
</ErrorBoundary>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/Primitives/Markup/Markup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { createMarkup, sanitizeAttributes } from "src/lib/html-element";

import { PrimitivesMarkup } from "src/types/primitives";
import React from "react";
import { Text } from "@radix-ui/themes";
import { getLabelAsString } from "src/lib/label-helpers";
import { styled } from "src/styles/stitches.config";

const StyledMarkup = styled("span", {});
const StyledMarkup = styled(Text, {});

const Markup: React.FC<PrimitivesMarkup> = (props) => {
const { as, markup } = props;
Expand Down
15 changes: 8 additions & 7 deletions src/components/Primitives/Metadata/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import CustomValue from "../Value/CustomValue";
import { DataList } from "@radix-ui/themes";
import Label from "../Label/Label";
import Value from "../Value/Value";
import { PrimitivesMetadataItem } from "src/types/primitives";
import CustomValue from "../Value/CustomValue";
import React from "react";
import Value from "../Value/Value";
import { getLabelAsString } from "src/lib/label-helpers";

const MetadataItem: React.FC<PrimitivesMetadataItem> = (props) => {
Expand All @@ -17,19 +18,19 @@ const MetadataItem: React.FC<PrimitivesMetadataItem> = (props) => {
.toLowerCase();

return (
<div role="group" data-label={dataAttribute}>
<Label as="dt" label={label} lang={lang} />
<DataList.Item role="group" data-label={dataAttribute}>
<Label as={DataList.Label} label={label} lang={lang} />
{customValueContent ? (
<CustomValue
as="dd"
as={DataList.Value}
customValueContent={customValueContent}
value={value}
lang={lang}
/>
) : (
<Value as="dd" value={value} lang={lang} />
)}
</div>
</DataList.Item>
);
};

Expand Down
5 changes: 3 additions & 2 deletions src/components/Primitives/Metadata/Metadata.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DataList } from "@radix-ui/themes";
import MetadataItem from "src/components/Primitives/Metadata/Item";
import { PrimitivesMetadata } from "src/types/primitives";
import { PrimitivesProvider } from "src/context/primitives-context";
Expand Down Expand Up @@ -34,7 +35,7 @@ const Metadata: React.FC<PrimitivesMetadata> = (props) => {
: undefined)}
>
{metadata.length > 0 && (
<StyledMetadata as={as} {...attributes}>
<DataList.Root orientation="vertical" {...attributes}>
{metadata.map((item, index) => {
const customValue = customValueContent
? parseCustomContent(item.label, customValueContent)
Expand All @@ -49,7 +50,7 @@ const Metadata: React.FC<PrimitivesMetadata> = (props) => {
/>
);
})}
</StyledMetadata>
</DataList.Root>
)}
</PrimitivesProvider>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DataList } from "@radix-ui/themes";
import MetadataItem from "src/components/Primitives/Metadata/Item";
import { PrimitivesProvider } from "src/context/primitives-context";
import { PrimitivesRequiredStatement } from "src/types/primitives";
Expand All @@ -6,7 +7,7 @@ import { getRealPropertyValue } from "src/lib/utils";
import { sanitizeAttributes } from "src/lib/html-element";
import { styled } from "src/styles/stitches.config";

const StyledRequiredStatement = styled("dl", {});
const StyledRequiredStatement = styled(DataList.Root, {});

const RequiredStatement: React.FC<PrimitivesRequiredStatement> = (props) => {
const { as, requiredStatement } = props;
Expand All @@ -27,7 +28,7 @@ const RequiredStatement: React.FC<PrimitivesRequiredStatement> = (props) => {
? { initialState: { delimiter: delimiter as string } }
: undefined)}
>
<StyledRequiredStatement as={as} {...attributes}>
<StyledRequiredStatement orientation="vertical" {...attributes}>
<MetadataItem item={requiredStatement} lang={attributes.lang} />
</StyledRequiredStatement>
</PrimitivesProvider>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Primitives/Value/CustomValue.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { Fragment, cloneElement } from "react";

import { DataList } from "@radix-ui/themes";
import { PrimitivesCustomValue } from "src/types/primitives";
import { getLabelEntries } from "src/lib/label-helpers";
import { styled } from "src/styles/stitches.config";
import { usePrimitivesContext } from "src/context/primitives-context";

const StyledCustomValue = styled("span", {});
const StyledCustomValue = styled(DataList.Value, {});

const CustomValue: React.FC<PrimitivesCustomValue> = ({
as = "dd",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Primitives/Value/Value.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { PrimitivesValue } from "src/types/primitives";
import Markup from "src/components/Primitives/Markup/Markup";
import { PrimitivesValue } from "src/types/primitives";
import React from "react";

const Value: React.FC<PrimitivesValue> = ({ as = "dd", lang, value }) => (
<Markup markup={value} as={as} lang={lang} />
Expand Down
1 change: 0 additions & 1 deletion src/components/UI/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const Tag = styled("div", {
// Custom
display: "inline-flex",
alignItems: "center",
borderRadius: "5px",
padding: "$1",
marginBottom: "$2",
marginRight: "$2",
Expand Down
Loading

0 comments on commit 383ccfd

Please sign in to comment.