Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Intercom component to accept style-related props #101

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

myleslinder
Copy link
Contributor

The supported props are the same as what intercom supports
as messenger attributes.


What does this PR introduce?

In a few bullet points, please describe the changes this Pull Request makes. e.g.:

Related issues

The supported props are the same as what intercom supports
as messenger attributes.
Intercoms attributes are snake_case but the props to the
component are camelCase to remain inline with the rest of the project.
@vercel
Copy link

vercel bot commented Sep 5, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/calibreapp/react-live-chat-loader/WJiRbhiEwUs2bwHuv5ibwc4yJhcX
✅ Preview: https://react-live-chat-loader-git-fork-myleslinder-f-a88a56-calibreapp.vercel.app

@@ -154,7 +170,10 @@ const Intercom = ({ color }: Props): JSX.Element | null => {
}

Intercom.defaultProps = {
color: '#333333'
color: '#333333',
alignment: 'left',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be right to maintain existing implementations?

@mikedijkstra
Copy link
Contributor

@myleslinder I found this in the Intercom Docs:

Messenger will revert to the default padding setting (20 / 20) on mobile

Therefore we need to ensure that on mobile the padding values are set to 20 and only set them to those specified by the props after the breakpoint.

Also, these values need to be added into window.intercomSettings to apply to the actual widget. We could leave this up to the implementor and just make a note in the README?

All props provided to the Intercom component are deemed to be the
source of truth for styling those aspects of the widget. This
ensures there's no style mismatch between the facade and the
loaded widget. A styling mismatch can still occur if a custom
icon is set in Intercom.

To mirror the default Intercom widget behavior padding props
are only applied on screen sizes with a width greater than 900px.
For smaller screen sizes the default padding of 20px is used.

Fix incorrect alignment proptypes default prop value
@myleslinder
Copy link
Contributor Author

I've addressed the issue with the incorrect alignment value being set on default props for proptypes.

I've also added the changes for the mobile padding and forwarding the provided props to window.intercomSettings. Re: intercom settings, I've forwarded all the provided props, as opposed to just the ones for padding, so that it's consistent that the values you provide to the Intercom component are all the source of truth for the facade and the loaded widget.

Let me know your thoughts on the changes.

@mikedijkstra
Copy link
Contributor

@myleslinder We're getting an issue building the Intercom component due to window.intercomSettings ?? {}. You probably can't see the logs so I'll paste them here:

09:37:50.930 | Failed to compile.
-- | --
09:37:50.938 | ../module/components/Intercom/index.js 108:87
09:37:50.938 | Module parse failed: Unexpected token (108:87)
09:37:50.939 | You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
09:37:50.939 | \|   const windowWidth = useWindowWidth();
09:37:50.939 | \|   useEffect(() => {
09:37:50.939 | >     window.intercomSettings = _objectSpread(_objectSpread({}, window.intercomSettings ?? {}), {}, {
09:37:50.939 | \|       alignment,
09:37:50.939 | \|       background_color: color,
09:37:50.940 | > Build error occurred
09:37:50.943 | Error: > Build failed because of webpack errors
09:37:50.943 | at build (/vercel/path0/website/node_modules/next/dist/build/index.js:13:900)
09:37:50.961 | npm ERR! code ELIFECYCLE
09:37:50.961 | npm ERR! errno 1
09:37:50.965 | npm ERR! react-live-chat-loader-example-app@0.0.1 build: `next build`
09:37:50.966 | npm ERR! Exit status 1
09:37:50.966 | npm ERR!
09:37:50.966 | npm ERR! Failed at the react-live-chat-loader-example-app@0.0.1 build script.
09:37:50.966 | npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
09:37:50.971 | npm ERR! A complete log of this run can be found in:
09:37:50.972 | npm ERR!     /vercel/.npm/_logs/2021-09-07T23_37_50_966Z-debug.log
09:37:50.987 | Error: Command "cd .. && npm run build && npm link website/node_modules/react && cd website && npm run build" exited with 1

README.md Outdated Show resolved Hide resolved
@benschwarz
Copy link
Member

Thanks so much for getting this over the line @myleslinder.

I'm happy with docs on review, is there anything else outstanding for you @mikedijkstra?

@mikedijkstra
Copy link
Contributor

mikedijkstra commented Sep 14, 2021

@myleslinder Build is now passing 👍

I tested the responsive behaviour locally and it seems Intercom isn't using the browser width alone. When I emulate a mobile device the real widget is locked at 20px and 20px, however when I resize the browser it's at the position set by the updated settings:

Screen Shot 2021-09-14 at 11 13 05 am

Screen Shot 2021-09-14 at 11 13 20 am

Therefore as it is now, we'll have mismatched positions on browser sizes < 900px as it's loading:

Screen Shot 2021-09-14 at 11 19 11 am

@mikedijkstra
Copy link
Contributor

Hi @myleslinder — Were you able to replicate the issue I saw above? Are you still interested in getting this wrapped up and over the line?

@benschwarz
Copy link
Member

Hey @myleslinder, we'd love to merge these improvements you've made. Did you get a chance to review the feedback?

@myleslinder
Copy link
Contributor Author

Hey, really sorry this slipped through the cracks. I'll get this over the line this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants