DEV Community

Cover image for Build KendoReact App with 10 Components
Abhay Singh Kathayat
Abhay Singh Kathayat

Posted on

2 1 1 2 1

Build KendoReact App with 10 Components

Step 1: Set Up the React Project

  1. Create a new React project:
   npx create-react-app productivity-dashboard
   cd productivity-dashboard
Enter fullscreen mode Exit fullscreen mode
  1. Install KendoReact and its dependencies:
   npm install @progress/kendo-react-buttons @progress/kendo-react-dropdowns @progress/kendo-react-inputs @progress/kendo-react-dateinputs @progress/kendo-react-grid @progress/kendo-react-charts @progress/kendo-react-dialogs @progress/kendo-react-layout @progress/kendo-react-notification @progress/kendo-react-progressbars
Enter fullscreen mode Exit fullscreen mode

Step 2: Build the App Structure

Here’s how we’ll structure the app:

  1. Header: Navigation and user settings.
  2. Sidebar: Quick links and filters.
  3. Main Content:
    • Task list with a Grid.
    • Progress tracking with a ProgressBar.
    • Calendar with a DatePicker.
    • Charts for visualizing productivity.
  4. Notifications: Display alerts using Notification.
  5. Modals: Use Dialog for adding tasks or editing details.

Step 3: Implement KendoReact Components

Below is the code for the app:

App.js

import React, { useState } from 'react';
import { Button } from '@progress/kendo-react-buttons';
import { DropDownList } from '@progress/kendo-react-dropdowns';
import { Input } from '@progress/kendo-react-inputs';
import { DatePicker } from '@progress/kendo-react-dateinputs';
import { Grid, GridColumn } from '@progress/kendo-react-grid';
import { Chart, ChartSeries, ChartSeriesItem, ChartCategoryAxis, ChartCategoryAxisItem, ChartValueAxis, ChartValueAxisItem } from '@progress/kendo-react-charts';
import { Dialog } from '@progress/kendo-react-dialogs';
import { Notification } from '@progress/kendo-react-notification';
import { ProgressBar } from '@progress/kendo-react-progressbars';
import { Drawer, DrawerContent, DrawerNavigation } from '@progress/kendo-react-layout';

const App = () => {
  const [tasks, setTasks] = useState([
    { id: 1, task: 'Complete KendoReact Challenge', dueDate: '2023-10-15', status: 'In Progress' },
    { id: 2, task: 'Prepare Presentation', dueDate: '2023-10-20', status: 'Not Started' },
  ]);
  const [selectedDate, setSelectedDate] = useState(new Date());
  const [isDialogOpen, setIsDialogOpen] = useState(false);
  const [newTask, setNewTask] = useState({ task: '', dueDate: '', status: 'Not Started' });
  const [notifications, setNotifications] = useState([]);

  const statusOptions = ['Not Started', 'In Progress', 'Completed'];

  const handleAddTask = () => {
    setTasks([...tasks, { ...newTask, id: tasks.length + 1 }]);
    setIsDialogOpen(false);
    setNotifications([...notifications, 'Task added successfully!']);
    setNewTask({ task: '', dueDate: '', status: 'Not Started' });
  };

  return (
    <div>
      {/* Header */}
      <header style={{ padding: '10px', backgroundColor: '#f0f0f0', display: 'flex', justifyContent: 'space-between' }}>
        <h1>Productivity Dashboard</h1>
        <DropDownList data={['Profile', 'Settings', 'Logout']} defaultValue="Profile" />
      </header>

      {/* Sidebar */}
      <Drawer>
        <DrawerNavigation>
          <ul>
            <li>Tasks</li>
            <li>Calendar</li>
            <li>Progress</li>
          </ul>
        </DrawerNavigation>
        <DrawerContent>
          {/* Main Content */}
          <div style={{ padding: '20px' }}>
            <Button onClick={() => setIsDialogOpen(true)}>Add Task</Button>

            {/* Task Grid */}
            <Grid data={tasks}>
              <GridColumn field="task" title="Task" />
              <GridColumn field="dueDate" title="Due Date" />
              <GridColumn field="status" title="Status" />
            </Grid>

            {/* Progress Bar */}
            <ProgressBar value={tasks.filter(task => task.status === 'Completed').length / tasks.length * 100} />

            {/* Calendar */}
            <DatePicker value={selectedDate} onChange={(e) => setSelectedDate(e.value)} />

            {/* Chart */}
            <Chart>
              <ChartCategoryAxis>
                <ChartCategoryAxisItem categories={tasks.map(task => task.task)} />
              </ChartCategoryAxis>
              <ChartValueAxis>
                <ChartValueAxisItem />
              </ChartValueAxis>
              <ChartSeries>
                <ChartSeriesItem type="bar" data={tasks.map(task => task.status === 'Completed' ? 1 : 0)} />
              </ChartSeries>
            </Chart>
          </div>
        </DrawerContent>
      </Drawer>

      {/* Add Task Dialog */}
      {isDialogOpen && (
        <Dialog title="Add Task" onClose={() => setIsDialogOpen(false)}>
          <Input
            value={newTask.task}
            onChange={(e) => setNewTask({ ...newTask, task: e.value })}
            placeholder="Task Name"
          />
          <DatePicker
            value={newTask.dueDate}
            onChange={(e) => setNewTask({ ...newTask, dueDate: e.value })}
            placeholder="Due Date"
          />
          <DropDownList
            data={statusOptions}
            value={newTask.status}
            onChange={(e) => setNewTask({ ...newTask, status: e.value })}
          />
          <Button onClick={handleAddTask}>Add</Button>
        </Dialog>
      )}

      {/* Notifications */}
      {notifications.map((message, index) => (
        <Notification key={index} type={{ style: 'success' }}>
          {message}
        </Notification>
      ))}
    </div>
  );
};

export default App;
Enter fullscreen mode Exit fullscreen mode

Step 4: Run the App

  1. Start the development server:
   npm start
Enter fullscreen mode Exit fullscreen mode
  1. Open your browser and navigate to http://localhost:3000.

Step 5: Showcase the Components

Here’s how the app uses the 10 KendoReact components:

  1. Button: For adding tasks and closing dialogs.
  2. DropDownList: For selecting status and user settings.
  3. Input: For entering task names.
  4. DatePicker: For selecting due dates.
  5. Grid: For displaying the task list.
  6. Chart: For visualizing task completion.
  7. Dialog: For adding new tasks.
  8. Notification: For showing success messages.
  9. ProgressBar: For tracking overall progress.
  10. Drawer: For the sidebar navigation.

Step 6: Enhance Design (Optional)

If you’re targeting the "Delightfully Designed" category:

  • Use ThemeBuilder to customize the app’s theme.
  • Use Figma UI Kits to design the layout and components.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay