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

Feature: create react vite capacitor example #73

Merged

Conversation

matiaspompilio
Copy link
Member

@matiaspompilio matiaspompilio commented Oct 19, 2023

What's this PR do?

Summary of changes in this PR or what it accomplishes.
The idea of ​​this example is to show a React Capacitor application setup.
This PR is made in order to set the initial project structure with a functional React application

@ulises-jeremias @rpmolina

Summary by CodeRabbit

  • New Feature: Introduced a new React-Vite-Capacitor example project with pre-configured dev tools and scripts for local development, formatting, linting, and production deployment.
  • New Feature: Added a new Cracked component with a slicer gradient effect and a Loading component with a spinning loader effect.
  • Documentation: Added comprehensive documentation covering project structure, configuration, components and styling, performance recommendations, and state management recommendations.
  • Chore: Implemented various configuration files for code formatting, linting, and type checking.
  • New Feature: Set up the basic structure for rendering the application routes and added a landing page.
  • Chore: Added a function to report web vitals metrics for performance monitoring.
  • New Feature: Configured the Vite PWA plugin for progressive web app support.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 19, 2023

Walkthrough

This pull request introduces a comprehensive React-Vite-Capacitor example project. It includes the setup of various development tools, project structure, and best practices documentation. The project also includes a basic routing setup, a landing page, and a loading component. The configuration files for ESLint, Prettier, and Vite are added, and web vitals reporting is set up.

Changes

File(s) Summary
.editorconfig, .eslintrc.js, .prettierrc.js, vite.config.ts Configuration files for EditorConfig, ESLint, Prettier, and Vite.
.env.example, .gitignore, .eslintignore, .prettierignore, .node-version Environment variables, ignored files for Git, ESLint, and Prettier, and Node.js version.
README.md, docs/*.md Documentation for the project, including best practices, performance optimizations, project configuration, project structure, and state management.
index.html, src/main.tsx, src/vite-env.d.ts, src/global.d.ts Setup for the React application, including the HTML entry point, main TypeScript file, and type declarations for Vite and global assets.
src/App.tsx, src/routes/AppRoutes.tsx Basic routing setup for the application.
src/pages/Landing.tsx, src/pages/Landing.css Landing page component and its styles.
src/components/Loading/Loading.tsx, src/components/Loading/loader.scss Loading component and its styles.
src/components/Animation/Cracked.tsx, src/components/Animation/cracked.css, src/components/Animation/slicer.scss Cracked animation component and its styles.
src/report-web-vitals.ts Setup for reporting web vitals metrics.
src/theme/index.ts Import for theme setup and global styles.

"In the land of code, where logic is king, 🤴
A new project is born, oh joy it will bring! 🎉
With structure so neat, and docs clear and bright, 📚
It's a beacon of learning, shining so bright. 💡
So here's to the coders, their spirits alight, 🔥
Crafting their art, in the soft glow of night. 🌙"


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 4

Commits Files that changed from the base of the PR and between 2e27632 and 5283be3.
Files ignored due to filter (5)
  • examples/react-vite-capacitor-example/package-lock.json
  • examples/react-vite-capacitor-example/package.json
  • examples/react-vite-capacitor-example/public/favicon.ico
  • examples/react-vite-capacitor-example/tsconfig.json
  • examples/react-vite-capacitor-example/tsconfig.node.json
Files selected for processing (33)
  • examples/react-vite-capacitor-example/.editorconfig (1 hunks)
  • examples/react-vite-capacitor-example/.env.example (1 hunks)
  • examples/react-vite-capacitor-example/.eslintignore (1 hunks)
  • examples/react-vite-capacitor-example/.eslintrc.js (1 hunks)
  • examples/react-vite-capacitor-example/.gitignore (1 hunks)
  • examples/react-vite-capacitor-example/.markdownlint.json (1 hunks)
  • examples/react-vite-capacitor-example/.node-version (1 hunks)
  • examples/react-vite-capacitor-example/.prettierignore (1 hunks)
  • examples/react-vite-capacitor-example/.prettierrc.js (1 hunks)
  • examples/react-vite-capacitor-example/README.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/COMPONENTS_AND_STYLING.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/PERFORMANCE.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/PROJECT_CONFIGURATION.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/PROJECT_STRUCTURE.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/README.md (1 hunks)
  • examples/react-vite-capacitor-example/docs/STATE_MANAGEMENT.md (1 hunks)
  • examples/react-vite-capacitor-example/index.html (1 hunks)
  • examples/react-vite-capacitor-example/src/App.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Animation/Cracked.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Animation/cracked.css (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Animation/slicer.scss (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Loading/Loading.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Loading/index.ts (1 hunks)
  • examples/react-vite-capacitor-example/src/components/Loading/loader.scss (1 hunks)
  • examples/react-vite-capacitor-example/src/global.d.ts (1 hunks)
  • examples/react-vite-capacitor-example/src/main.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/pages/Landing.css (1 hunks)
  • examples/react-vite-capacitor-example/src/pages/Landing.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/report-web-vitals.ts (1 hunks)
  • examples/react-vite-capacitor-example/src/routes/AppRoutes.tsx (1 hunks)
  • examples/react-vite-capacitor-example/src/theme/index.ts (1 hunks)
  • examples/react-vite-capacitor-example/src/vite-env.d.ts (1 hunks)
  • examples/react-vite-capacitor-example/vite.config.ts (1 hunks)
Files skipped from review due to trivial changes (28)
  • examples/react-vite-capacitor-example/.editorconfig
  • examples/react-vite-capacitor-example/.env.example
  • examples/react-vite-capacitor-example/.eslintignore
  • examples/react-vite-capacitor-example/.eslintrc.js
  • examples/react-vite-capacitor-example/.gitignore
  • examples/react-vite-capacitor-example/.markdownlint.json
  • examples/react-vite-capacitor-example/.node-version
  • examples/react-vite-capacitor-example/.prettierignore
  • examples/react-vite-capacitor-example/.prettierrc.js
  • examples/react-vite-capacitor-example/README.md
  • examples/react-vite-capacitor-example/docs/COMPONENTS_AND_STYLING.md
  • examples/react-vite-capacitor-example/docs/PERFORMANCE.md
  • examples/react-vite-capacitor-example/docs/PROJECT_CONFIGURATION.md
  • examples/react-vite-capacitor-example/docs/PROJECT_STRUCTURE.md
  • examples/react-vite-capacitor-example/docs/README.md
  • examples/react-vite-capacitor-example/docs/STATE_MANAGEMENT.md
  • examples/react-vite-capacitor-example/index.html
  • examples/react-vite-capacitor-example/src/components/Animation/slicer.scss
  • examples/react-vite-capacitor-example/src/components/Loading/Loading.tsx
  • examples/react-vite-capacitor-example/src/components/Loading/index.ts
  • examples/react-vite-capacitor-example/src/components/Loading/loader.scss
  • examples/react-vite-capacitor-example/src/global.d.ts
  • examples/react-vite-capacitor-example/src/pages/Landing.css
  • examples/react-vite-capacitor-example/src/pages/Landing.tsx
  • examples/react-vite-capacitor-example/src/report-web-vitals.ts
  • examples/react-vite-capacitor-example/src/theme/index.ts
  • examples/react-vite-capacitor-example/src/vite-env.d.ts
  • examples/react-vite-capacitor-example/vite.config.ts
Additional comments (Suppressed): 6
examples/react-vite-capacitor-example/src/App.tsx (1)
  • 1-17: The new hunk looks good overall. It properly sets up a React application with routing and lazy loading. However, please ensure that the environment variable VITE_APP_BASE_URL is correctly set in your .env file and that it matches the base URL of your application. This is important for the BrowserRouter to function correctly.
examples/react-vite-capacitor-example/src/routes/AppRoutes.tsx (1)
  • 1-12: The new hunk introduces a Routes component from react-router-dom that wraps a Route component. The Route component has a path prop set to "/" and its element prop set to the Landing component. This means that when the application's URL path is "/", the Landing component will be rendered. This is a common pattern for defining routes in a React application using react-router-dom. The code is clear, concise, and follows best practices for routing in a React application.
examples/react-vite-capacitor-example/src/main.tsx (1)
  • 1-17: The use of createRoot from react-dom/client is a part of the new concurrent mode in React. Ensure that the rest of your application is compatible with concurrent mode, as it can lead to unexpected behavior if not used correctly. Also, be aware that as of my knowledge cutoff in September 2021, concurrent mode is still experimental and its APIs are subject to change.
examples/react-vite-capacitor-example/src/components/Animation/cracked.css (3)
  • 18-18: The animation-direction property is set to alternate, which means the animation will reverse direction each cycle, going from 0% to 100%, then 100% to 0%, and so on. If this is the intended behavior, then it's fine. However, if you want the animation to always start from 0% after reaching 100%, you should remove this property.

  • 39-39: The clip-path property is used to create complex shapes. However, it's not fully supported in all browsers (especially IE). If cross-browser compatibility is a concern, consider using an alternative method to achieve the same effect.

  • 40-40: The animation shorthand property is used here, which includes the animation name, duration, timing function, and delay. The forwards value for the animation-fill-mode property means that the animation will apply the property values for the time the animation ends. If this is the intended behavior, then it's fine. However, if you want the animation to reset to its initial state after it ends, you should remove this value.

Comment on lines +10 to +20
const Cracked: FC<CrackedProps> = ({ children }) => (
<div className="bg-text">
<div className="slicer-gradient">
{new Array(40).fill(1).map((_, i) => (
<div key={`slice-${i + 1}`} className="text">
{children}
</div>
))}
</div>
</div>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

The Cracked component is creating 40 identical divs with the same content. This could potentially lead to performance issues if the content passed as children is complex or large. Consider if there's a more efficient way to achieve the desired effect, or if the number of divs can be reduced.

- {new Array(40).fill(1).map((_, i) => (
+ {new Array(10).fill(1).map((_, i) => (

Comment on lines +3 to +4
import './slicer.scss';
import './cracked.css';
Copy link
Contributor

Choose a reason for hiding this comment

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

Both .scss and .css files are being imported. This could lead to confusion and inconsistency in the codebase. Consider standardizing the use of one preprocessor or the other for maintainability.

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals(console.log);
Copy link
Contributor

Choose a reason for hiding this comment

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

You are logging web vitals to the console. This is fine for development, but in a production environment, you might want to send these metrics to an analytics endpoint. Make sure to conditionally log these metrics based on the environment.

- reportWebVitals(console.log);
+ if (process.env.NODE_ENV === 'development') {
+   reportWebVitals(console.log);
+ } else {
+   // replace `analyticsEndpointFunction` with your actual function to report metrics
+   reportWebVitals(analyticsEndpointFunction);
+ }

.cracked {
font-family: Coolvetica, Arial;
font-size: 16.74rem;
line-height: 1.15 !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

The use of !important is generally discouraged in CSS as it breaks the natural cascading in your stylesheets. It's better to use more specific selectors or restructure your CSS to avoid the need for !important. However, if it's absolutely necessary in this case, it's acceptable.

Copy link
Member

@ulises-jeremias ulises-jeremias left a comment

Choose a reason for hiding this comment

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

🔥

@ulises-jeremias ulises-jeremias merged commit 2e06ffd into nanlabs:main Oct 20, 2023
5 checks passed
alecastro-nan pushed a commit to alecastro-nan/frontend-reference that referenced this pull request Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants