4

Importing Ant Design Components

 2 years ago
source link: https://www.uxpin.com/studio/blog/integrate-with-ant-design-npm/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to Import Ant Design to UXPin? An npm Integration Guide

Ant Design NPM Integration

Component-driven prototyping significantly improves user testing while providing stakeholders with realistic product design expectations. UXPin’s npm integration enables design teams to use open-source component libraries to design fully functioning, high-fidelity prototypes.

Get on board the code-based design revolution with UXPin’s Merge technology and npm Integration. Discover more about component-driven prototyping that maximizes the use of design systems, improves design handoffs, and scales design significantly.

Bring UI components via Git repo, Storybook, or through our newest npm integration. Learn more about the last option here: Merge npm integration.

What is UXPin Merge?

UXPin Merge is a code-based technology allowing you to sync a component library hosted in a repository, Storybook or as an npm package to UXPin’s design editor. Designers can use these UI components to build prototypes that look and function like the final product.

Any changes engineers (or the design system team) make to functional components in the repository automatically sync to UXPin, notifying design teams of the update. Merge includes version control, allowing team members to switch to an older design system version if needed.

This single source of truth enhances collaboration while reducing the burden on DesignOps and the DS team to manage two design systems–one for design tools and the other for code.

What is UXPin’s npm Integration?

merge component manager npm packages import library

UXPin Merge required engineering expertise to set everything up until now. Not every team has valuable engineering resources for the setup, so we came up with a way of integrating npm components to UXPin.

Merge’s npm Integration gives designers complete control over installing and managing open-source component libraries available as npm packages. Designers can import and customize components to meet their prototyping needs using an intuitive interface. It requires zero coding skills to set everything up.

If you want to learn about npm for designer, read our introductory guide: What is npm package?

The Benefits of Working With Ant Design

Ant Design is the product of the Ant Group–a Chinese-based conglomerate of several tech/finance organizations, including Alipay, Huabei, and Yu’ebao, to name a few.

ant design

Organizations have used Ant Design to build a multitude of applications, including B2B, B2C, and enterprise products. The comprehensive design system includes React, Angular, and Vue component libraries, with a complementary icon set. You also get Ant Design Mobile for building native applications.

Ant Design npm Integration With UXPin Merge

Ant Design’s React component library is available as an npm package (antd). Designers can import Ant React components using UXPin’s npm Integration and customize properties in the Merge Component Manager.

logo uxpin merge npm packages

If design teams want to use Ant Design with other design tools, they must use one of Ant Design’s static vector-based UI kits, but with UXPin’s npm Integration, designers have access to the same components engineers use.

Component-driven prototyping with Ant Design creates a single source of truth between designers and engineers while ensuring the highest consistency between UX and product teams.

With UXPin’s npm Integration, you can choose which Ant Design React props you want to import–color, size, icons, states, etc.

Assigning Properties in Merge Component Manager

Our npm Integration includes Merge Component Manager–your central control for importing and managing each Ant Design’s component properties.

UXPin’s npm Integration works with React components, so you can follow Ant Design’s React documentation to reference which props you want to import. Once you set these up in Merge Component Manager, the component’s properties appear in UXPin’s Properties Panel.

For example, there are six types or variants of an Ant Design button:

  • Primary
  • Ghost
  • Dashed
  • Default

These button types (and all other properties) appear as a dropdown in the Properties Panel for designers to choose. Props can appear as text fields, checkboxes, code editors, etc., depending on the component.

Connecting UXPin to the Ant Design npm Package

Step 1

Navigate to your UXPin dashboard and click “New Project.”

Hj-hhCrtTZ0dgQMsTxXUD52r0pUt0_lO8StT-8SyMZfILhlZmmk_WFBu9W0W1N1MtqaevTegw-sRSrz8GhvmOslwdH_kpUMn774x0yJA4DcsRfj-9g1yJw28c2Hq-ibDX0ZSYcEYyc1EGPYXyzF-mcQ

Step 2

Name your project and click “Create New Project.”

WXG_8UJOYGVwvCSKDPFG70FYu8FnsfIZy0KvdAQz2sQi2xsWxLEu66s8-Aug6YTEoSYZHT8Ylhe82p29RER-1jc5SbRjIWPtfkvbXfYCadkWcUGPoaGWn7-R0QjdwxXkZz5aba6Ys4zQejKoWjBW2tU

Step 3

Click “New prototype” to open the project in UXPin’s design canvas.

C-t3zqIHeG5JjnYVMKEHuej2r3wZHm87jfIdwt7rah8yzNG6IlzOPN-oKkBGxg9ccjw9JOfTNQHFaH1CPITcFDNX79UCAe6Sz4Ccd_VXCJPkTbl9JBXm5xmIWCDmy6Ncf0YA-p-BoIbIqR1EteBf3iA

Step 4

Click the dropdown at the bottom of the Design System Libraries tab in the lefthand sidebar, and click “New library.”

DZEEJXYqbfs_cIZqbI-0waDfyLzBxrgc5mviwgvUbD-xWqFE1AQdZUkNt-pNdRQhyfOKY6QBw4f1ziLcYhEIbnLA36Bfy1jdPTVN9s517TNOKCZc9L4l7FC54UJlxtCf336swh8MPCedsAPrjVegJlQ

Your sidebar and available libraries may differ from the example.

Step 5

Select “Import React Components” and click “Next.”

import npm package

Step 6

Name your library. This name is purely for your reference and won’t impact the import.

You also need to grab the npm package repository name, which you find under Install on Ant Design’s npm page. Copy and paste the Install contents from npm into the “Library package name” field (delete everything preceding antd).

CaLNoFbyJ2a2JzxrLb0Seq2XSLPZijkXRrEN9OIVxGZDWgRP5i-rJw4BbR0WvihYykYu7MqNMylOvqnu1SwyWzqBcNYzgcTv197o3EdA1iTQhuyW36mPs_JDKvHC5gifRudNlptaC2oksvFhHW8g8Do

To import component styling properties, Merge requires the path to Ant Design’s CSS (antd/dist/antd.css). You can find this under Usage in Ant Design’s React installation instructions.

UML4wR-_9y2rxUHG1umM8Ovy2c10VEeiDtJX8mj6IssSVqQpOBO0NlYiqz1jDYRn1oCMfdLWXQF0icwVSYlt8St1jsZLEB9uUuYHRnozXGt1vzCbFYgeqKGAG0ab7by7rWsWgwWGXqS8hout8Ima5Z4

Importing Ant Design Components

UXPin will automatically redirect you to the canvas once you complete the npm integration. Now it’s time to select the Ant Design components you want to import.

Step 1

From the lefthand sidebar, click “Open Merge Component Manager.”

ZEx9Wdx48KMZ5_73NmSCfyhu7zGFWmOEeXUcU0KJVM0WljWNA5HqA5nUcQje_K0xYwTacmXjhGpycSNsjIXofoarPscTzTE38kCeeO1_dtllfZQSlTCGjHP6GvWOCJR0eI3ZitNBASfJf5XfdnG4P2A

Merge Component Manager will open in a new tab.

Step 2

Click “Add new component.”

viAiQyIFL9DVNjvpR9wFHbAcI4PJxypTNVYU2XEtdtamT-CyDMNszECYBhIN1IWn8gsnwvE5szJ4olgllY-WBlmNOM66GhPWTxNTbDyFe8sMgEqsq0xAv9he_YLGeHGPxgocsghi5NbrTRlLMo1ank4

Step 3

Enter the name of the component you want to import.

You’ll find the correct naming convention in the Ant Design docs under Component API. Ant Design’s components use CamelCase with no spaces. Always capitalize the first letter. For example, Date Picker would be DatePicker.

kWf8CSuv-sAY95e1Qk_in_M0hHocmTQNd7r_r7s27CvzqY06UfrPVRFVhiC6qsFTC6mc38HLXg-RWQpBYQS_U3eiWFumdpr1tT8KU1rb2xLoJ88c8bATYmsA8wGq0ZGE-pb_5SY3HDXEojtjlAnwZBg

For this tutorial, we will import an Ant Design Button as our first component and add it to a new category called General. We recommend using the same categories as Ant Design’s docs, so designers and engineers have the same reference point.

You can add multiple components to a single import, saving you time repeating steps two and three.

Click “Import Components.”

0uuZQHU9pNwW0DgUUFA8gHUFfvKHp9TK6JA61Ge_NiOkshdJhGrRLY6cRZsVjcXaOrLFeaMhwzsFyPj0vkK8OcOb8b06cihdoOJtpnEcuZ9cB_vK8iJcnLH2l02PnqByBUhPn9X4cGlmUO_TrU3iA-4

Step 4

Click “Publish Changes” in the top right to initialize the import process.

CXXaXVlCrhlXXVYikl91wxJ6WObAa4IP1EoDf_z0WU6j1Iv0uR1Z2_eKLw7X3Bfd6sHlNN8LUfnD-SGhKlXuwBKftuZVv5-o_1gKxrlVidW9XfMDtLsR9gGGorOZFGayRcF88C8UUn3_pD6Do8m1ju0

The first time you do this for a new component, it might take a minute or two.

oY22GaCltA64gKF7v4inDejoai_uEKfVO_oRtUp-sos9zXqTSVbLAnvIqzZsl4Eghsqg7s9tsT4lbtqQFsNcW8ueeKjaZSUeCgujHbkCIDF2LZKSVPEthTA46tr3n_nch6JSoMAl7p-CGeKC6jAIwUQ

Step 5

Once the import is complete, click “Refresh Library” to update the changes in your project library.

O-BKx-qQ4CGYzh0krbrq7-1Fq2OKthz-VNEMm-Y7J-dIBC2GvnsvGgi-TKg7EoRhU9KmQyI9ncT4JhnNoM-CAYKsA9uJNJRK_VcVrOjrruiGJxQJhfgVXVWn9PUagVWngngzORlRDz-1XmxVg5qw5HM

If you follow these instructions step-by-step, you’ll notice you have a category (General) and your first component (Button) in the left sidebar.

Step 6

Click on the Button to begin adding properties. You can find these React props in Ant Design’s documentation under API in Components > General > Button.

pRg7OZ6ZcvhokvCgtD5M5OkFJhDN-n3gjyxs0WkVuaFkrvkmrFTFpdXsYraMq_bD6O-qy25KTsuovBTWQ6IZuYKiOizDNIGTq4AXLxKIirIOtKsJee8_DRbyQJvzR0jkD78Nd5Rs7lnoC5ZBf4L0jj8

Adding Component Properties with Merge Component Manager

Let’s add a few Ant Design button properties using the React props from the documentation.

WQOtRYxvj0BkW2x3-4seg9I-VlB6wQOSOjb7x_n4YG9gelYGi97Mj3w047pDsWlUMpkZX5hPJzDb88tvGMxRsgHD-8z4emtTvDYxCaLZm5leltgDbkSy8TYTw-qlrEZ44u3xj4i032sBRSLx3XarujE

Button Type: Step 1

The React button type prop imports the six Ant Design button styles.

  • Property name: enter “type” (always use lowercase for props)
  • Display name: This is for your reference, but something descriptive that both designers and engineers use–we’ve gone with “Type” to keep things uniform
  • Description: Add a short description or instructions for designers–we’ve used “Type of button”
  • Property type: “enum”–allows you to create a dropdown display the six styles
  • Property control: “select”
  • Options: Add the options from Ant Design’s API docs–primary, ghost, dashed, link, text, default
  • Default value: Your preference–we’ve gone with “default” as per Ant Design’s docs

As you complete the component’s properties, you’ll notice a component preview will appear and change according to your preferences.

Button Type: Step 2

Once you have completed all the fields, click “Add property.”

iHJYlian4RwZwNh5eNQCnzWII5kIx6BMMW659yEJ5Z_1aHFPcdSB8i5zitDeH5l3cX8RlMJJYfuhb6veOOrH5GVxzu0kHzCbTFSBZ0XDeipCWA-Wg3gO7lVaBKEHqyifSSCvetG2zNT4gYcCNuSZwrw

Then “Save changes.”

W7HZ-ao-Dw3NzGIq1GgWddLzg5ICJKNqj53UuwGage8PqqWrotjUfkm0gtkV2z8AGuWgtmr9ZHja5DaOv7CcTZ8gKY1-8ZCFQaOAhnnGFt405xSdFzyXB34okfJ930E_HEEzESihQFnDFJN8boqhxRM

Lastly, “Publish library changes.”

VQ8IqMOx9dG_igPYVBiDGlgqdgU_wjUM7V2cqMc_CuBDQYWSl70ySk627q6f4kUV5vroD1MfvhWIgfKuXz9yQHg-sAN5TxfpXQy-kmpd0B2A7YlKqyd1IvGaegZlpg7mhT_QClkD76OA-VC_CjIkre8

Component-Driven Prototyping in UXPin

Once you import the Ant Design components and properties you need, prototyping in UXPin is as simple as drag-and-drop to build layouts. We created this simple email sign-up form using three Ant Design components in less than a minute.

GW91brSr1iBsRQ4l1D8j76ncloF_ZaSi3KA3An5LFKns-IDO3ZW34CY_F64uMxdM6RrmQdcBI8_DHu9DhSEfQhbZ3T_zdQrvbfSSLT_rv8odcBWIG6lEdXVXxdQq6j5phSy61grtC8R3CzpzY422ufw

When you select an Ant Design component, the properties you created in Merge Component Manager appear in the righthand Properties Panel.

Try building an Ant Design prototype with UXPin’s npm integration. Discover how component-driven prototyping can revolutionize your product development workflows to deliver better user experiences to your customers.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK