Skip to content

Conversation

@mocca102
Copy link
Contributor

@mocca102 mocca102 commented Jan 9, 2024

  • Renaming CioPlpContext -> CioPlp (this can be anything else depending on what the team decides)
    • CioPlpContext is definitely wrong since this is just the provider not the actual context
  • Refactor CioPlp to accept children renderProps to expose the provider values
  • Adds client side tests for CioPlp
  • Move the CioPlp tests into a folder

Most of the changes are just renaming CioPlpContext -> CioPlp. The actual code changes are small

@linear
Copy link

linear bot commented Jan 9, 2024

CSL-2888 [MVP] - PLP Grid Component

Business Outcome:

  • As a Consumer of the Library I want a component that I can plug in to my React App so that I can integrate with Constructor easily

Definition of done:

Additional Notes:

  • May be blocked by stories currently in dev/in review

@@ -0,0 +1,56 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here just moved the file into CioPlp

expect(html).toContain('<div>Test</div>');
});

it('renders CioPlp provider with render props on the server', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new test case for renderProps pattern

@@ -0,0 +1,59 @@
import React from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for client side

@@ -1,13 +1,52 @@
import React from 'react';
import { useCioPlpContext } from '../../PlpContext';
import React, { useMemo, useState } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is previously CioPlpContext

<div>{JSON.stringify(state?.cioClientOptions)}</div>
</div>
<PlpContext.Provider value={contextValue}>
{typeof children === 'function' ? children(contextValue) : children}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provider accepts direct children or children function for renderProps pattern support

@@ -0,0 +1,13 @@
import { createContext, useContext } from 'react';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved useCioPlpContext into a hooks file
No new code here

*/
export type IncludeRenderProps<P, RenderProps> = P & {
children?: (props: RenderProps) => ReactNode;
export type IncludeRenderProps<ComponentProps, ChildrenFunctionProps> = ComponentProps & {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IncludeRenderProps should accept both a children function {() => ()} or children components <ChildComponent />

@@ -1,5 +1,4 @@
#storybook-root {
display: flex;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was breaking the hooks examples

@mocca102 mocca102 requested a review from a team January 10, 2024 00:18
Copy link
Contributor

@esezen esezen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. Tagging @Mudaafi to see if he wants to review this before we 🚢

@mocca102 mocca102 merged commit c4efe0e into main Jan 11, 2024
@mocca102 mocca102 deleted the csl-2888-refactor-plp-context branch January 11, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants