Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
pipx run build server
pipx run build server/example-client --outdir server/dist
- name: Upload sdist and wheel as artifacts
uses: actions/upload-artifact@v6
uses: actions/upload-artifact@v7
with:
name: dist
path: server/dist
Expand All @@ -88,7 +88,7 @@ jobs:

steps:
# Download sdist and wheel from dist job
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v8
with:
path: dist
# Publish to PyPI using trusted publishing
Expand Down
4 changes: 4 additions & 0 deletions client/component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ View the frontend Typescript documentation [here](https://diamondlightsource.git

## Installation

Currently, only React 18 is supported.

### `pnpm add @diamondlightsource/davidia`

## Vite configuration

Use `vite < 8` in your devDependencies.

Some davidia dependencies require a global object to be defined when used in Vite applications. Add the following to your vite.config.ts:

```js
Expand Down
10 changes: 6 additions & 4 deletions client/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"url": "git+https://github.com/DiamondLightSource/davidia.git"
},
"private": false,
"version": "1.1.0",
"version": "1.2.0",
"type": "module",
"scripts": {
"build": "tsc && vite build",
Expand All @@ -23,8 +23,10 @@
},
"publishConfig": {
"exports": {
".": "./dist/index.js",
"types": "./dist/index.d.ts",
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./index.css": "./dist/index.css"
}
},
Expand All @@ -43,7 +45,7 @@
"ndarray-tile": "^1.0.3",
"ndarray-unsqueeze": "^1.0.3",
"react-colorful": "^5.8.0",
"react-draggable": "^4.7.0",
"react-draggable": "^4.7.1",
"react-icons": "^5.7.0",
"react-select": "^5.10.2",
"react-use-websocket": "^4.13.0",
Expand Down
2 changes: 1 addition & 1 deletion client/component/src/AspectConfigModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function AspectConfigModal(props: PropsWithChildren<AspectConfigModalProps>) {
const [aspectRatio, setAspectRatio] = useState<number>(2.0);

const initType = getAspectType(initAspect);
console.log('Set initial type', props);
if (initType != aspectType) {
console.log('Set initial type', props);
setAspectType(initType);
if (initType === 'number') {
setAspectRatio(initAspect as number);
Expand Down
21 changes: 20 additions & 1 deletion client/component/src/ConnectedPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ interface ConnectedPlotProps {
port?: string;
/** The universally unique identifier */
uuid: string;
/**
* If enabled, forces the plot to shrink or expand to keep the image flush with the axes.
* Has no effect if the aspect is not equal.
*/
tightAxes?: boolean;
/**
* Children to customize the toolbar. If undefined then use default toolbar, if null, disable toolbar,
* otherwise use given children
*/
customToolbarChildren?: React.ReactNode;
}

/**
Expand All @@ -239,6 +249,8 @@ function ConnectedPlot({
hostname = '127.0.0.1',
port = '80',
uuid,
tightAxes = false,
customToolbarChildren = undefined,
}: ConnectedPlotProps) {
const [plotProps, setPlotProps] = useState<AnyPlotProps | null>();
const [lineData, setLineData] = useState<LineData[]>([]);
Expand Down Expand Up @@ -648,7 +660,14 @@ function ConnectedPlot({

let currentProps = plotProps;
if (currentProps) {
currentProps = { ...currentProps, batonProps, updateSelection, selections };
currentProps = {
...currentProps,
batonProps,
updateSelection,
selections,
tightAxes,
customToolbarChildren,
};
}

if (currentProps) {
Expand Down
2 changes: 1 addition & 1 deletion client/component/src/LinePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function createDataCurve(
curveType={curveType}
glyphType={p.glyphType ?? GlyphType.Circle}
glyphSize={p.pointSize}
width={p.width}
width={p.width ?? 1}
visible={visible}
/>
);
Expand Down
1 change: 0 additions & 1 deletion client/component/src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ function Modal(props: PropsWithChildren<ModalProps>) {
<Fragment key={'Modal-' + toggleTitle}>
{!toggleHidden && toggle}
{showModal && props.children && (
/* @ts-expect-error see https://github.com/react-grid-layout/react-draggable/issues/807, fix post 4.7.0 */
<Draggable key={toggleTitle} handle="strong" nodeRef={rootRef}>
<div hidden={!showModal} className={styles.modal} ref={rootRef}>
<div
Expand Down
1 change: 0 additions & 1 deletion client/component/src/Modeless.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function Modeless(props: PropsWithChildren<ModelessProps>) {

const modeless =
showModeless && props.children ? (
/* @ts-expect-error see https://github.com/react-grid-layout/react-draggable/issues/807, fix post 4.7.0 */
<Draggable key={title} handle="strong" nodeRef={rootRef}>
<div hidden={!showModeless} ref={rootRef} className={styles.modeless}>
<div
Expand Down
4 changes: 3 additions & 1 deletion client/component/src/PlotCustomizationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ export function PlotCustomizationContextProvider(
} = useSelections([], props.selectionsListener);

const isSurfacePlot = plotType === 'Surface';
if (!selections && props.selections) setSelections(props.selections);
if (props.selections != undefined && selections != props.selections) {
setSelections(props.selections);
}

const newUpdateSelection = useMemo(() => {
if (isSurfacePlot) {
Expand Down
2 changes: 1 addition & 1 deletion client/example/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@diamondlightsource/davidia-example",
"private": true,
"version": "1.1.0",
"version": "1.2.0",
"type": "module",
"scripts": {
"start": "vite",
Expand Down
Loading
Loading