import React, { CSSProperties, useState } from 'react'; import { Meta } from '@storybook/react/types-6-0'; import { Story } from '@storybook/react'; import PlateViewer from './PlateViewer'; import { PlateViewerProps } from './types'; import { getNumericPosition, getPositionLabel } from './utils'; import { Divider } from 'antd'; export default { title: 'Components/PlateViewer', component: PlateViewer, parameters: {}, } as Meta; const Template: Story = (args) => { return ; }; const SBS_96_COLUMN_COUNT = 12; const SBS_384_COLUMN_COUNT = 24; const SBS_1536_COLUMN_COUNT = 48; const SBS_1536_ROW_COUNT = 36; const wells = Array(SBS_1536_ROW_COUNT * SBS_1536_COLUMN_COUNT) .fill(1) .map(() => Math.floor(Math.random() * 100)); function getConfluence(position: number): number { return wells[position]; } export const AllFeatures96Wells = Template.bind({}); AllFeatures96Wells.args = { rowCount: 8, columnCount: SBS_96_COLUMN_COUNT, wellClick(numericPosition: number) { // tslint:disable-next-line: no-console console.log('Clicked well', getPositionLabel(numericPosition, SBS_96_COLUMN_COUNT), 'at position', numericPosition); }, disableWellClick: (position) => { const confluence = getConfluence(position); if (confluence > 75) { return { disabled: true, disabledMessage: 'Confluence must be in 50-75 range', }; } return false; }, wellValueGetter: getConfluence, wellContent(position) { const confluence = getConfluence(position); if (confluence >= 50 && confluence <= 75) { return confluence; } return null; }, wellSelectionConfiguration: { multiple: true, enabled: true, labelSelectionEnabled: true, showCount: true, }, wellStyle(position) { const confluence = getConfluence(position); if (confluence < 50) { return {}; } else if (confluence <= 75) { return { backgroundColor: 'rgba(99, 163, 117, 0.8)', color: '#30523a', fontSize: 10, paddingTop: 4, }; } else { return { backgroundColor: 'rgba(255, 90, 90, 0.8)', cursor: 'not-allowed', }; } }, wellTootipContent(position) { const confluence = getConfluence(position); return `Confluence: ${confluence}%`; }, labelConfiguration: { show: true, }, sliderConfiguration: { enabled: true, minValue: 0, initialMin: 50, initialMax: 75, maxValue: 100, valueFormatter(value: number) { return `${value}%`; }, enableSelectAll: true, }, }; export const SingleSelect96Wells = Template.bind({}); SingleSelect96Wells.args = { rowCount: 8, columnCount: SBS_96_COLUMN_COUNT, wellContent(position) { return getConfluence(position); }, wellSelectionConfiguration: { labelSelectionEnabled: true, enabled: true, }, labelConfiguration: { show: true, }, wellStyle(position) { const confluence = getConfluence(position); const style = { fontSize: 10, paddingTop: 4 }; if (confluence < 50) { return { ...style }; } else if (confluence <= 75) { return { ...style, backgroundColor: 'rgba(99, 163, 117, 0.8)', }; } else { return { ...style, backgroundColor: 'rgba(255, 90, 90, 0.8)', }; } }, }; export const Empty96 = Template.bind({}); Empty96.args = { rowCount: 8, columnCount: SBS_96_COLUMN_COUNT, labelConfiguration: { show: true, }, }; export const Empty384 = Template.bind({}); Empty384.args = { rowCount: 16, columnCount: SBS_384_COLUMN_COUNT, labelConfiguration: { show: true, }, }; export const Colors1536 = Template.bind({}); Colors1536.args = { rowCount: 16, columnCount: SBS_1536_COLUMN_COUNT, labelConfiguration: { show: true, }, wellStyle: (position: number) => { const confluence = getConfluence(position); const originalStyle = { height: 15, width: 15, }; if (confluence < 50) { return { ...originalStyle }; } else if (confluence <= 75) { return { ...originalStyle, backgroundColor: 'rgba(99, 163, 117, 0.8)', }; } else { return { ...originalStyle, backgroundColor: 'rgba(255, 90, 90, 0.8)', }; } }, };