visit
In this article, we will extend the functionality of AWS Amplify Studio to build an application from Figma and import the components into React. The connection between Figma and React, with the help of Amplify, creates reusable React components that save you time and from writing long lines of code. The conversion process from Figma to code is seamless and makes it efficient for developers to build faster (which is probably why Abode ).
npm install -g @aws-amplify/cli
The Primitives page: This page binds to AWS Amplify Studio, which comprises all the styles for the pre-built components. Changing the content of this page will affect the look of the React UI library from the Figma components.
The My Components page: This page gives you control to edit, change, and create components, and it comes with pre-built components.
The Examples page: This page shows the example designs of some custom components from the My Components page.
This tutorial will use two components from the My Components page: the NavBar and FormCheckout UI.
Select AWS Amplify from the list of services. Once in the All Apps dashboard, click the New app button and select Build an app from the dropdown.
npx create-react-app no-code
Click the launch studio button as it takes you to the page showing the staging environment for no-code.
Sync with Figma. This dialog box will allow you to paste the Figma file link from the My Components page.
FormCheckout from Figma's imported components is the same as displayed in Amplify Studio.
Remember that for this command to work, install the AWS Amplify CLI globally, as stated in the prerequisites section.Running the command will prompt our program with an authorization message.
If you encounter challenges or any error log messages in the terminal, it will probably be that you haven’t configured AWS.Check out if you face this challenge.
The installation creates a new folder ui-components in the src directory, which contains all the pulled UI components from Amplify Studio.
npm install @aws-amplify/ui-react aws-amplify
Styles
In the application's entry point, the index.js file, import the CSS file. Copy and update the index.js file with this code which is responsible for the look and feel of the app:// src/index.js
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import '@aws-amplify/ui-react/styles.css'; // add this
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Fonts
Amplify UI ships with the default fonts, during installation of Amplify UI dependency. In the
public/index.html
file, copy and paste the following Google fonts CDN links in the <head>
element:// public/index.html
...
<head>
<link rel="preconnect" href="//fonts.googleapis.com" />
<link rel="preconnect" href="//fonts.gstatic.com" crossorigin />
<link
href="//fonts.googleapis.com/css2?family=Inter:slnt,[email protected],100..900&display=swap"
rel="stylesheet"
/>
</head>
...
To display the components FormCheckout and NavBar, navigate to the
src/App.js
file and remove all the code. Next, update the file with this code:// src/App.js
import { FormCheckout, NavBar } from './ui-components';
const App = () => {
return (
<>
<NavBar />
<FormCheckout marginTop='5em' />
</>
);
}
export default App;
npm start
The development server runs on
//localhost:3000
.Want to deploy this React app to the web? Check out this resource that guides you step by step using AWS Amplify.