Skip to content

Commit

Permalink
Copy css into build; update listener example in Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmbake committed Oct 31, 2023
1 parent 80f5279 commit 63b63e2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 48 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Or using yarn:
yarn add react-calendar-plus
```

## Usage
## Example Usage

```javascript
```typescript
import React from 'react';
import { Calendar, CalendarEvent, CalendarEventStore } from 'react-calendar-plus';

Expand Down Expand Up @@ -67,13 +67,32 @@ function CalendarDemo() {

// Support for listening for calendar events:
calenderEventStore.onAdd((event: CalendarEvent) => {
console.log("Added event:", event);
// Call server to add event
fetch('https://api.example.com/events', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(event)
});
});
calenderEventStore.onUpdate((event: CalendarEvent) => {
console.log("Updated event:", event);
// Call server to add event
fetch(`https://api.example.com/events/${event.id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(event)
});
});
calenderEventStore.onDelete((event: CalendarEvent) => {
console.log("Deleted event:", event);
fetch(`https://api.example.com/events/${event.id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
});
});

return (
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
],
"scripts": {
"build": "npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:types && npm run build:demo",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json && cp ./src/calendar.css ./dist/cjs/",
"build:esm": "tsc -p tsconfig.esm.json && cp ./src/calendar.css ./dist/esm/",
"build:umd": "webpack --mode production",
"build:types": "tsc -p tsconfig.types.json",
"build:demo": "webpack --config webpack.demo.config.js --mode production && cp demo/index.html dist/demo",
Expand Down
33 changes: 21 additions & 12 deletions src/calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,31 @@
border-left: 3px solid rgb(101, 219, 57);
}

.calendar-event.success {
background-color: #28a745;
border-color: #269940;
.calendar-month-view {
display: grid;
grid-template-columns: repeat(7, 1fr);
}

.calendar-event.warning {
background-color: #ffc107;
border-color: #ffb507;
.weekdays-row {
display: contents; /* makes the children of this div to respect the parent grid */
}

.calendar-event.danger {
background-color: #dc3545;
border-color: #d2253a;
.weekday {
background-color: #f7f7f7;
padding: 5px;
text-align: center;
font-weight: bold;
}

.calendar-event.primary {
background-color: #007bff;
border-color: #006fee;
.calendar-day {
background-color: #ffffff;
padding: 5px;
border: 1px solid #e0e0e0;
min-height: 120px;
}

.calendar-day.inactive {
background-color: #f7f7f7;
border: none;
cursor: none;
}
28 changes: 0 additions & 28 deletions src/views/month-view.css

This file was deleted.

1 change: 0 additions & 1 deletion src/views/month-view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import CalendarEventStore from "../calendar-event-store";
import { areDatesEqual } from "../utils/date";
import "./month-view.css";

interface Props {
activeDate: Date;
Expand Down

0 comments on commit 63b63e2

Please sign in to comment.