add text highlighting controls

only disable highlighting text when dragging widgets
This commit is contained in:
2025-07-22 13:41:32 -07:00
parent ab03d43aff
commit b066c7f023
3 changed files with 19 additions and 5 deletions
@@ -5,7 +5,7 @@ export default function Widget({ title }) {
const styles = recipe(); const styles = recipe();
return ( return (
<chakra.div css={styles.root}> <chakra.div >
<chakra.div css={styles.header} <chakra.div css={styles.header}
className="widget-handle" className="widget-handle"
// style={{ padding: '4px', cursor: 'move', background: '#ddd' }} // style={{ padding: '4px', cursor: 'move', background: '#ddd' }}
@@ -25,6 +25,15 @@ export default function WidgetCanvas() {
console.log('Updated layout:', newLayout) console.log('Updated layout:', newLayout)
}; };
// don't allow text highlighting when dragging
const handleDragStart = () => {
document.body.style.userSelect = "none";
};
// allow text highlighting all other times
const handleDragStop = () => {
document.body.style.userSelect = "";
};
return ( return (
<chakra.div height="100%" width="100%"> <chakra.div height="100%" width="100%">
<ResponsiveGridLayout <ResponsiveGridLayout
@@ -36,6 +45,8 @@ export default function WidgetCanvas() {
margin={[10, 10]} // [horizontal, vertical] gap margin={[10, 10]} // [horizontal, vertical] gap
onLayoutChange={onLayoutChange} onLayoutChange={onLayoutChange}
draggableHandle=".widget-handle" // Make only the header draggable draggableHandle=".widget-handle" // Make only the header draggable
onDragStart={handleDragStart}
onDragStop={handleDragStop}
> >
{layout.map((item) => ( {layout.map((item) => (
<chakra.div key={item.i} css={styles.root}> <chakra.div key={item.i} css={styles.root}>
+7 -4
View File
@@ -55,7 +55,10 @@ const widgetRecipe = defineSlotRecipe({
root: { root: {
bg: "base100", bg: "base100",
borderRadius: "md", borderRadius: "md",
p: "1" p: "1",
border: "1px solid",
borderColor: "{base300}",
textAlign: "center",
}, },
header: { header: {
bg: "base100", bg: "base100",
@@ -73,9 +76,9 @@ const config = defineConfig({
theme: { theme: {
semanticTokens: { semanticTokens: {
colors: { colors: {
base100: { value: {base: "#f7f9fa", _dark: "#787b73"}}, base100: { value: {base: "#f6f9faff", _dark: "#787b73"}},
base200: { value: {base: "#eef2f6", _dark: "#242424"}}, base200: { value: {base: "#e6ecf1ff", _dark: "#242424"}},
base300: { value: {base: "#dfe5ed", _dark: "#60645a"}}, base300: { value: {base: "#d3dae4ff", _dark: "#60645a"}},
// primary: { value: {base: "#9cd855", _dark: "#629631"}}, // primary: { value: {base: "#9cd855", _dark: "#629631"}},
primary: { value: {base: "#2B98F8", _dark: "#2B98F8"}}, primary: { value: {base: "#2B98F8", _dark: "#2B98F8"}},
// primaryLt: { value: {base: "#c9e9a0", _dark: "#92948e"}}, // primaryLt: { value: {base: "#c9e9a0", _dark: "#92948e"}},