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

feat: added network notice banner as a resuable component #112

Merged
merged 3 commits into from
May 31, 2024

Conversation

frazarshad
Copy link
Contributor

@frazarshad frazarshad commented May 29, 2024

closes: #114

Description

This PR adds NetworkBanner (originally implemented in this PR) as a reusable component for dapps. The purpose of this component is to query the /network-config endpoint to find any notices and display them.

The use of this component dapp-econ-gov can be seen in this PR Agoric/dapp-econ-gov#104

How to test

  • copy dapp-econ-gov and ui-kit repos and checkout to the `` and feat/notice-banner branch respectively
  • run yarn build in the ui-kit repo to create the dist directory
  • run yarn add /full/path/to/ui-kit/packages/react-components in dapp-econ-gov to install it as a dependancy.

Security Considerations

Scaling Considerations

Documentation Considerations

Testing Considerations

@frazarshad frazarshad requested a review from samsiegart May 29, 2024 13:24
Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

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

Can you add the issue to the PR description please? It would be helpful to see the requirements.

@@ -25,8 +25,8 @@
"prepack": "yarn build"
},
"dependencies": {
"@agoric/rpc": "^0.9.0",
"@agoric/web-components": "^0.15.0",
"@agoric/rpc": "0.9.1-dev-02a116c.0+02a116c",
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to keep these versions the same as in the local packages so they build from the workspace.

@@ -0,0 +1,90 @@
import { FiX } from 'react-icons/fi';
import { GrAnnounce } from 'react-icons/gr';
import { motion, AnimatePresence } from 'framer-motion';
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unsure about importing framer-motion into this library, the bundle size is already really large. Maybe we can start without the collapse-on-hide animation, or just do it with regular CSS.

},
};

const networkConfigAtom = atomWithStorage(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just have the component take the loaded network config JSON as an argument instead of hardcoding and fetching the network configs here. I have some ideas for handling network-configs more holistically in AgoricProvider, but I'm still not convinced we want the react components to deal with network configs.

@samsiegart
Copy link
Contributor

In reference to Agoric/dapp-psm#94, I'm having trouble testing with yarn link as well (probably since we updated to yarn v4). I'm eager to put an example dapp in this package (#86) so we can test new components easier.

Copy link

cloudflare-workers-and-pages bot commented May 30, 2024

Deploying ui-kit with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab2cc72
Status: ✅  Deploy successful!
Preview URL: https://24c15ad2.ui-kit-dwm.pages.dev
Branch Preview URL: https://feat-notice-banner.ui-kit-dwm.pages.dev

View logs

@frazarshad
Copy link
Contributor Author

In reference to Agoric/dapp-psm#94, I'm having trouble testing with yarn link as well (probably since we updated to yarn v4). I'm eager to put an example dapp in this package (#86) so we can test new components easier.

yarn link was also troublesome for me. i've added instructions in the description on how to test these changes

@frazarshad frazarshad requested a review from rabi-siddique May 30, 2024 16:57
@frazarshad
Copy link
Contributor Author

Can you add the issue to the PR description please? It would be helpful to see the requirements.

No issue exists previously. created one and linked it in the PR

@frazarshad frazarshad requested a review from samsiegart May 30, 2024 17:04
Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

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

No issue exists previously. created one and linked it in the PR

I see, I was wondering to see the motivation for creating this component. I think importing react-components into our inter dapps to use this might be heavy handed for now, but I have no qualms about providing a component like this in general, and it's a good exercise.

run yarn build in the ui-kit repo to create the dist directory

Heads up, we want to run yarn prepack from the top-level of ui-kit normally. This will build rpc, web-components, and react-components in order since they depend on eachother, in case you make changes to more than just react-components.

Also, you can remove the "WIP" from the PR now that it's out of draft.

@@ -33,7 +33,8 @@
"@leapwallet/elements": "0.12.1",
"chain-registry": "1.28.0",
"react": "18.2.0",
"react-dom": "18.2.0"
"react-dom": "18.2.0",
"react-icons": "^5.2.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use something similar from https://heroicons.com/ and copy them into packages/react-components/src/lib/icons? Just trying to avoid adding dependencies and bundle size where possible. Chain-registry and Leap Elements already push the bundle size of this lib over 3MB which really pushes it, I'd like to figure out how to trim this down at some point.

export const NoticeBanner = ({
notices,
}: {
notices: Array<NetworkNotice>;
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -0,0 +1,22 @@
export type NetworkNotice = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's export these from packages/react-components/src/lib/utils/index.ts as well so they're accessible to consumers and in the typedocs

@frazarshad frazarshad changed the title WIP: feat: added network notice banner as a resuable component feat: added network notice banner as a resuable component May 30, 2024
@frazarshad frazarshad force-pushed the feat/notice-banner branch from ddb4e2a to 2de60fb Compare May 30, 2024 18:14
@frazarshad frazarshad requested a review from samsiegart May 30, 2024 18:14
Copy link
Contributor

@samsiegart samsiegart left a comment

Choose a reason for hiding this comment

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

Tested on Agoric/dapp-econ-gov#104 and looks great!

@frazarshad frazarshad force-pushed the feat/notice-banner branch from 2de60fb to ab2cc72 Compare May 31, 2024 04:23
@frazarshad frazarshad merged commit 45cf5c8 into main May 31, 2024
2 checks passed
@frazarshad frazarshad deleted the feat/notice-banner branch May 31, 2024 09:57
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.

Create a banner component to show notices
2 participants