Skip to content

Commit

Permalink
docs(examples): migrate custom data table state manager to vite (carb…
Browse files Browse the repository at this point in the history
…on-design-system#15275)

* docs(examples): migrate custom data table state manager to vite

* chore: fix readme

* removed warning by changing the size name

---------

Co-authored-by: Guilherme Datilio Ribeiro <[email protected]>
  • Loading branch information
alisonjoseph and guidari authored Nov 30, 2023
1 parent 1567d46 commit 2633b45
Show file tree
Hide file tree
Showing 29 changed files with 4,311 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ yarn install
npm install


yarn start
yarn dev
# or
npm run start
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the
result.
Open [http://localhost:5173/](http://localhost:5173/) with your browser to see
the result.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "custom-data-table-state-manager-vite",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@carbon/react": "latest",
"carbon-icons": "latest",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"use-debounce": "^10.0.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.54.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"sass": "1.69.5",
"vite": "^5.0.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { ExampleCustomDataTableApp } from './ExampleCustomDataTableApp'

function App() {

return (
<ExampleCustomDataTableApp/>
)
}

export default App
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright IBM Corp. 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import CustomDataTable from './components/CustomDataTable';

import {
rowsMany as demoRowsMany,
columns as demoColumns,
sortInfo as demoSortInfo,
} from './table-data';


export const ExampleCustomDataTableApp = () => {
return (
<CustomDataTable
columns={demoColumns}
rows={demoRowsMany}
sortInfo={demoSortInfo}
hasSelection={true}
pageSize={5}
start={0}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use '@carbon/react';

body {
margin: 2rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import "./index.scss"

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const TABLE_SIZE = {
/**
* Regular size.
*/
REGULAR: 'normal',
REGULAR: 'lg',

/**
* Tall size.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
Loading

0 comments on commit 2633b45

Please sign in to comment.