Skip to content

Commit

Permalink
fix: updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
shibisuriya committed Jun 1, 2024
1 parent b74158e commit e26f847
Show file tree
Hide file tree
Showing 90 changed files with 1,171 additions and 661 deletions.
48 changes: 32 additions & 16 deletions packages/docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { defineConfig } from "vitepress";
// https://vitepress.dev/reference/site-config
export default defineConfig({
srcDir: "./src/docs/",
title: "Declarative Gridstack docs",
title: "Declarative Gridstack",
description: "Docs for Declarative Gridstack.",
logo: "static/images/logo.jpeg",
cleanUrls: true,
base: "/declarative-gridstack/",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "Concepts", link: "/concepts/gridstack-containers" },
{ text: "Showcase", link: "/showcase/ubuntu-desktop" },
{ text: "Concepts", link: "/concepts/gridstack-grids" },
{ text: "Guides", link: "/guides/react/simple" },
{ text: "API", link: "/api/react/gridstack-items" },
],
Expand Down Expand Up @@ -47,8 +48,8 @@ export default defineConfig({
text: "Concepts",
items: [
{
text: "Gridstack Containers",
link: "/concepts/gridstack-containers",
text: "Gridstack Grids",
link: "/concepts/gridstack-grids",
},
{
text: "Gridstack Items",
Expand Down Expand Up @@ -85,8 +86,19 @@ export default defineConfig({
text: "React",
collapsed: false,
items: [
{ text: "Adding items", link: "/guides/react/adding-items/" },
{ text: "CRA (create-react-app)", link: "/guides/react/cra/" },
{
text: "Using CRA (Create React App)",
link: "/guides/react/cra",
},
{ text: "Adding items", link: "/guides/react/adding-items" },
{
text: "Removing items",
link: "/guides/react/removing-items",
},
{
text: "Simple",
link: "/guides/react/simple",
},
{
text: "Drag and drop into trash",
link: "/guides/react/drag-and-drop-into-trash",
Expand All @@ -99,14 +111,6 @@ export default defineConfig({
text: "Nested",
link: "/guides/react/nested",
},
{
text: "Removing items",
link: "/guides/react/removing-items",
},
{
text: "Simple",
link: "/guides/react/simple",
},
{
text: "Using APIs",
link: "/guides/react/using-apis",
Expand All @@ -116,14 +120,26 @@ export default defineConfig({
{
text: "Vue",
collapsed: true,
items: [],
items: [
{
text: "Nested",
link: "/guides/vue/nested",
},
{
text: "Using APIs",
link: "/guides/vue/using-apis",
},
],
},
],
},
],
},
socialLinks: [
{ icon: "github", link: "https://github.com/vuejs/vitepress" },
{
icon: "github",
link: "https://github.com/shibisuriya/declarative-gridstack",
},
],
},
});
5 changes: 3 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
},
"dependencies": {
"@declarative-gridstack/react": "workspace:^",
"@declarative-gridstack/vue": "workspace:^",
"@loadable/component": "^5.16.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-json-view-lite": "^0.9.7"
"react-json-view": "^1.21.3"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import {
GridstackContainer,
GridstackItem,
} from "@declarative-gridstack/react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";

import { Widget } from "../components/Widget";
import { Widget } from "./components/Widget";

import "./styles.css";

import styles from "./styles.module.css";
import JsonViewer from "./components/JsonViewer";

function AddingItems() {
const [layout, setLayout] = useState([
{
id: "1",
x: 0,
y: 0,
w: 12,
w: 6,
h: 2,
data: {
type: "calendar",
Expand All @@ -36,9 +37,9 @@ function AddingItems() {
const newId = String(getNewId());
return {
id: newId,
x: 0,
x: newId % 2 === 0 ? 0 : 6,
y: 0,
w: 12,
w: 6,
h: 2,
data: {
type: "calendar",
Expand All @@ -58,10 +59,12 @@ function AddingItems() {
return (
<Fragment>
<div>
<button onClick={addItem}>Add item</button>
<button onClick={addItem} className={styles.btn}>
Add item
</button>
</div>
<div className="row">
<div className="flex-1">
<div className="flex-1 bg">
<GridstackContainer items={layout} setLayout={setLayout}>
{layout.map((widget) => {
return (
Expand All @@ -79,9 +82,7 @@ function AddingItems() {
})}
</GridstackContainer>
</div>
<div className="flex-2">
<JsonView data={layout} style={darkStyles} class="json-viewer" />
</div>
<JsonViewer json={layout} />
</div>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, { Fragment, useRef, useState } from "react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";
import {
GridstackContainer,
GridstackItem,
Expand Down Expand Up @@ -315,9 +313,6 @@ function DragAndDrop() {
})}
</GridstackContainer>
</div>
<div className="flex-1">
<JsonView data={layout} style={darkStyles} />
</div>
</div>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, { Fragment, useRef, useState } from "react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";

import {
GridstackContainer,
Expand Down Expand Up @@ -201,9 +199,6 @@ function Nested() {
</GridstackContainer>
)}
</div>
<div className="flex-2">
<JsonView data={layout} style={darkStyles} class="json-viewer" />
</div>
</div>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {
GridstackContainer,
GridstackItem,
} from "@declarative-gridstack/react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";
import { Widget } from "../components/Widget";
import ItemContainer from "../components/ItemContainer";
import { Widget } from "./components/Widget";
import ItemContainer from "./components/ItemContainer";

import "./styles.css";

Expand All @@ -25,6 +23,18 @@ function Remove() {
data: "10/10/1990",
},
},
{
id: "2",
x: 0,
y: 0,
w: 12,
h: 2,
data: {
type: "calendar",
title: "A calendar widget",
data: "10/10/1990",
},
},
]);

const remove = (id) => {
Expand Down Expand Up @@ -58,9 +68,6 @@ function Remove() {
})}
</GridstackContainer>
</div>
<div className="flex-1">
<JsonView data={layout} style={darkStyles} class="json-viewer" />
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {
GridstackContainer,
GridstackItem,
} from "@declarative-gridstack/react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";
import { Widget } from "../components/Widget";
import { Widget } from "./components/Widget.jsx";

import "./styles.css";

Expand All @@ -15,7 +13,7 @@ function Simple() {
id: "1",
x: 0,
y: 0,
w: 12,
w: 6,
h: 2,
data: {
type: "calendar",
Expand All @@ -27,7 +25,7 @@ function Simple() {
return (
<div>
<div className="row">
<div className="flex-1">
<div className="flex-1 bg">
<GridstackContainer items={layout} setLayout={setLayout}>
{layout.map((widget) => {
return (
Expand All @@ -45,9 +43,6 @@ function Simple() {
})}
</GridstackContainer>
</div>
<div className="flex-1">
<JsonView data={layout} style={darkStyles} class="json-viewer" />
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {
GridstackContainer,
GridstackItem,
} from "@declarative-gridstack/react";
import { JsonView, darkStyles } from "react-json-view-lite";
import "react-json-view-lite/dist/index.css";
import { Widget } from "../components/Widget";
import { Widget } from "./components/Widget";

import "./styles.css";

Expand Down Expand Up @@ -56,9 +54,6 @@ function UpdatingDimensions() {
})}
</GridstackContainer>
</div>
<div className="flex-1">
<JsonView data={layout} style={darkStyles} class="json-viewer" />
</div>
</div>
</div>
);
Expand Down
31 changes: 0 additions & 31 deletions packages/docs/src/components/react/apis/styles.css

This file was deleted.

25 changes: 25 additions & 0 deletions packages/docs/src/components/react/components/JsonViewer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from "react";

import loadable from "@loadable/component";
const ReactJson = loadable(() => import("react-json-view"));

function JsonViewer(props) {
const { json } = props;
return (
<div className="m-4">
<ReactJson
src={json}
theme={"twilight"}
displayDataTypes={false}
enableClipboard={false}
enableAdd={false}
enableEdit={false}
displayObjectSize={false}
iconStyle={"circle"}
indentWidth={5}
/>
</div>
);
}

export default JsonViewer;
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
.widget {
background-color: red;
background-color: #b39cd0;
height: 100%;
display: flex;
justify-content: center;
color: black;
align-items: center;
text-align: center;
padding: 10px;
}

:global(.grid-stack) {
background-color: #fbeaff;
}
Loading

0 comments on commit e26f847

Please sign in to comment.