Skip to content

Commit

Permalink
Merge pull request #75 from bruceharrison1984/dev
Browse files Browse the repository at this point in the history
0.2.1
  • Loading branch information
bruceharrison1984 authored Jan 12, 2023
2 parents bb08bd2 + 0cefff7 commit f3a4d72
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 331 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['turbo', 'prettier'],
extends: ['plugin:react-hooks/recommended', 'turbo', 'prettier'],
plugins: ['sort-imports-es6-autofix', '@typescript-eslint'],
rules: {
'react/jsx-key': 'off',
Expand Down
5 changes: 3 additions & 2 deletions apps/schedulely-docs/docs/Usage/Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ description: Functions used for interacting with Schedulely
---

While Schedulely expects developers to implement their own components to achieve their desired goals, we have provided clear interfaces for how actions should be handled.
The ActionProvider is used under the hood to take in functions as arguments, memoize them, and pass them in to the calendar components. This makes state management within
Schedulely simple, and ensures we are re-rendering the bare minimum.
The ActionProvider is used under the hood to take in functions as arguments and pass them in to the calendar components. This makes state management within
Schedulely simple, and ensures we are re-rendering the bare minimum. If you are creating custom calendar components, these actions are available to you on each components
respective interface, and can be implemented(or not implemented) however you choose.

**All actions return `() => null` unless explicitly overridden.**

Expand Down
13 changes: 4 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
"eslint": "^8.24.0",
"eslint-config-next": "^12.0.8",
"eslint-config-prettier": "^8.3.0",
"eslint-config-turbo": "latest",
"eslint-plugin-react": "7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"eslint-config-turbo": "latest",
"husky": "^8.0.1",
"prettier": "latest",
"turbo": "1.6.2",
Expand Down
10 changes: 10 additions & 0 deletions packages/Schedulely/__stories__/Schedulely.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const NoEvents = () => {
const props: SchedulelyProps = {
events: [],
initialDate: new Date().toISOString(),
actions: {
onMoreEventsClick: (events) => console.log(events),
onEventClick: (event) => console.log(event),
onDayClick: (day) => console.log(day),
},
};

return (
Expand All @@ -39,6 +44,11 @@ export const DefaultTheme = () => {
const props: SchedulelyProps = {
events: storyEvents,
initialDate: new Date().toISOString(),
actions: {
onMoreEventsClick: (events) => console.log(events),
onEventClick: (event) => console.log(event),
onDayClick: (day) => console.log(day),
},
};
return (
<Schedulely
Expand Down
25 changes: 0 additions & 25 deletions packages/Schedulely/__tests__/layouts/EventWeekLayout.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ let mockIsHighlighted = jest.fn((eventId: string) => false);
let mockEventOnClickHandler = jest.fn(() => {});

let mockSetParentContainerRef = jest.fn((eventId: string) => {});
let mockSetRefFromKey = jest.fn((eventId: string) => {});
let mockIsEventVisible = jest.fn((eventId: string) => true);

jest.mock('@/hooks', () => ({
useComponents: jest.fn(() => ({
Expand All @@ -65,8 +63,6 @@ jest.mock('@/hooks', () => ({
})),
useEventIntersection: jest.fn(() => ({
setParentContainerRef: mockSetParentContainerRef,
setRefFromKey: mockSetRefFromKey,
isEventVisible: mockIsEventVisible,
})),
}));

Expand All @@ -80,11 +76,6 @@ describe('EventWeekLayout', () => {
);
});

afterEach(() => {
mockIsEventVisible.mockClear();
mockSetRefFromKey.mockClear();
});

describe.each(events.map((x) => x.summary))('event %s', (value) => {
let eventDomObject: HTMLElement;

Expand Down Expand Up @@ -125,22 +116,6 @@ describe('EventWeekLayout', () => {
describe('useEventIntersection', () => {
it('setParentContainerRef is called on the parent', () =>
expect(mockSetParentContainerRef).toHaveBeenCalledTimes(1));

it('isEventVisible is called', () =>
expect(mockIsEventVisible).toHaveBeenCalledTimes(events.length));

it('isEventVisible is called with each eventId', () =>
expect(mockIsEventVisible.mock.calls.flat().sort()).toEqual(
events.map((x) => x.id).sort()
));

it('setRefFromKey is called', () =>
expect(mockSetRefFromKey).toHaveBeenCalledTimes(events.length));

it('setRefFromKey is called with each eventId', () =>
expect(mockSetRefFromKey.mock.calls.flat().sort()).toEqual(
events.map((x) => x.id).sort()
));
});

describe('getGridEndIndex', () => {
Expand Down
Loading

0 comments on commit f3a4d72

Please sign in to comment.