You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pages/console/uibuilder/bestpractices.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
exportconst meta = {
2
-
title: `Figma-to-Code best practices`,
3
-
description: `Constraints of Amplify Studio's Figma-to-React capabilities`,
2
+
title: `Figma to Code best practices`,
3
+
description: `Constraints of Amplify Studio's Figma to React capabilities`,
4
4
};
5
5
6
-
We're constantly improving Amplify Studio to make Figma-to-React code conversion better but there are some constraints that need to be taken into account.
6
+
We're constantly improving Amplify Studio to make Figma to React code conversion better but there are some constraints that need to be taken into account.
7
7
8
8
## Make sure to mark frames as components in Figma
9
9
Amplify Studio only converts Figma components. If you only have a Figma "frame", Studio will ignore it because frames tend to be used to layout a set of components.
@@ -14,21 +14,21 @@ Learn more about how Figma components work and how to create them with the video
14
14
15
15
## Fonts aren't automatically integrated
16
16
17
-
By default, Amplify Studio doesn't automatically export the font from the Figma file and download it as part of your `src/ui-components/` folder. To workaround this, you can include the font like you'd usually do yourself in your React app.
17
+
By default, Amplify Studio doesn't automatically export the font from the Figma file and download it as part of your `src/ui-components/` folder. To workaround this, you can include the font like you'd usually do yourself in your React app.
18
18
19
19
Review the [Adding Fonts](https://create-react-app.dev/docs/adding-images-fonts-and-files/) documentation from the Create React App on how to configure this.
20
20
21
21
## Try to use Figma Auto layout whenever possible
22
22
23
-
Figma "Auto layout" can make a component significantly more responsive than used fixed position of elements. Think of Figma's Auto layout as "Flexboxes" (`display: flex`) in CSS.
23
+
Figma "Auto layout" can make a component significantly more responsive than used fixed position of elements. Think of Figma's Auto layout as "Flexboxes" (`display: flex`) in CSS.
24
24
25
25
Learn more about how Figma's Auto layout works with the video below from the Figma team:
26
26
27
27
<iframewidth="560"height="315"src="https://www.youtube-nocookie.com/embed/PNJxeD29ZTg"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"allowfullscreen></iframe>
28
28
29
29
## Represent UI element states in code (hover, active)
30
30
31
-
Amplify Studio currently doesn't support Figma-to-React code conversion of UI state. For example, if you want to add a hover effect to a button, you need to [override the component behavior in code](/console/uibuilder/override/#set-hover-states-on-icons) instead of creating a hover variant in Figma.
31
+
Amplify Studio currently doesn't support Figma to React code conversion of UI state. For example, if you want to add a hover effect to a button, you need to [override the component behavior in code](/console/uibuilder/override/#set-hover-states-on-icons) instead of creating a hover variant in Figma.
32
32
33
33
## Figma variants must have the same child elements
Copy file name to clipboardExpand all lines: src/pages/console/uibuilder/responsive.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
exportconst meta = {
2
2
title: `Responsive Components`,
3
-
description: `Learn how to configure Figma-to-Code components in order for them to scale according to breakpoints`,
3
+
description: `Learn how to configure Figma to Code components in order for them to scale according to breakpoints`,
4
4
};
5
5
6
6
You can use Amplify Studio to dynamically toggle between different component variants based on your app's breakpoint. For example, you can have the navigation bar shrink to a smaller size as the window gets smaller.
@@ -9,7 +9,7 @@ You can use Amplify Studio to dynamically toggle between different component var
9
9
10
10
## 1. Set your preferred breakpoints in Figma
11
11
12
-
To apply breakpoints to components generated by Amplify Studio, you must have a Figma account with the [AWS Amplify Theme Editor](https://www.figma.com/community/plugin/1040722185526429545/AWS-Amplify-Theme-Editor) plugin installed.
12
+
To apply breakpoints to components generated by Amplify Studio, you must have a Figma account with the [AWS Amplify Theme Editor](https://www.figma.com/community/plugin/1040722185526429545/AWS-Amplify-Theme-Editor) plugin installed.
13
13
14
14
By default, all Amplify UI provides the following [breakpoints as part of the Amplify UI theme](https://ui.docs.amplify.aws/react/theming/responsive#breakpoints):
15
15
@@ -41,11 +41,11 @@ To make a component responsive, create different variants for the component base
41
41
42
42
<Calloutwarning>
43
43
44
-
**IMPORTANT:** The variants are required to have the same <strong>component structure</strong>. Elements within the component structure must also use the same <strong>layout method</strong> (i.e. "Auto Layout" or manual).
44
+
**IMPORTANT:** The variants are required to have the same <strong>component structure</strong>. Elements within the component structure must also use the same <strong>layout method</strong> (i.e. "Auto Layout" or manual).
45
45
46
46
If the variants don't have the same structure, then Amplify Studio will not be able to import the component.
47
47
48
-
To customize child elements in variants, you can use the eye icon to hide and show elements in different variants.
48
+
To customize child elements in variants, you can use the eye icon to hide and show elements in different variants.
49
49
50
50

51
51
@@ -72,7 +72,7 @@ With your design complete in Figma, import and render your component using Ampli
72
72
73
73
Figma allows users to create variants based on multiple properties. For example, a component may need `breakpoint` variants (small, medium, and large) and `displayMode` variants (light mode, dark mode).
74
74
75
-
If your component has any variant properties in addition to `breakpoint`, additional steps are required for responsiveness. All additional properties <i>must</i> be given inline values, or the component will not be responsive.
75
+
If your component has any variant properties in addition to `breakpoint`, additional steps are required for responsiveness. All additional properties <i>must</i> be given inline values, or the component will not be responsive.
76
76
77
77
In the below examples, the `ResponsiveToolbar` component has both `breakpoint` and `displayMode` variants. In the first example, the component will not automatically be responsive.
78
78
@@ -100,7 +100,7 @@ function App() {
100
100
exportdefaultApp;
101
101
```
102
102
103
-
Alternatively, multidimensional variants can be separated into separate components, each with only the `breakpoint` variant property. For example, the above component could be split into `ResponsiveToolbarLight` and `ResponsiveToolbarDark`, and rendered conditionally.
103
+
Alternatively, multidimensional variants can be separated into separate components, each with only the `breakpoint` variant property. For example, the above component could be split into `ResponsiveToolbarLight` and `ResponsiveToolbarDark`, and rendered conditionally.
Copy file name to clipboardExpand all lines: src/pages/console/uibuilder/slots.mdx
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
exportconst meta = {
2
2
title: `Component slots`,
3
-
description: `Add component slots to Amplify-generated Figma-to-code components. Use this to support nested components or collections in React code.`,
3
+
description: `Add component slots to Amplify-generated Figma to code components. Use this to support nested components or collections in React code.`,
4
4
};
5
5
6
6
Component slots allow you to nest other components as React code within your Studio-generated UI components. You can use component slots to create dynamically generated child components, like Comments on a Post, or to replace a child element altogether.
7
7
8
8
## Adding a component slot
9
-
First, you'll need a component.
9
+
First, you'll need a component.
10
10
1. Log into Amplify and [navigate to Studio](/console/adminui/start/).
11
11
12
12
2. On the left-hand navigation bar, click UI Library
@@ -18,44 +18,44 @@ First, you'll need a component.
18
18
19
19

20
20
21
-
Next, you'll add a component slot to this component.
22
-
1. On the left-hand side, you'll see the elements of your component. Select a Figma **Frame** () within your component.
21
+
Next, you'll add a component slot to this component.
22
+
1. On the left-hand side, you'll see the elements of your component. Select a Figma **Frame** () within your component.
23
23
24
24
In this example, the "Area" frame is selected.
25
25
26
26
2. On the right-hand panel, click the "Convert to a slot" button. This will add a new prop to your UI component. Any JSX element you pass into that prop will be rendered in the generated component slot.
27
27
28
-
3. Optionally, change your property name.
28
+
3. Optionally, change your property name.
29
29
30
30
In this example, the property has been renamed "comments"
31
31
32
32

33
33
34
34
<Calloutwarning>
35
35
36
-
Want to undo your component slot creation?
36
+
Want to undo your component slot creation?
37
37
38
38
Locate your component slot in the **Component properties** (top-right corner), click the triple-dot menu, and click **Erase property** to remove the component slot.
39
39
40
40
</Callout>
41
41
42
42
## Render the component with component slots in React code
43
43
### Importing your component
44
-
Once you've added a component slot to your component, click the **Get component code** button at the bottom of the screen to see instructions on the next steps.
44
+
Once you've added a component slot to your component, click the **Get component code** button at the bottom of the screen to see instructions on the next steps.
45
45
1. Copy the `amplify pull` command, and run it in your Terminal
46
46
2. Copy the import code and paste it in your React app code
47
47
3. Lastly, render the component
48
48
49
49
```jsx
50
50
/*Import your component*/
51
-
import {
52
-
Ampligram
51
+
import {
52
+
Ampligram
53
53
} from'./ui-components'
54
54
55
55
functionApp() {
56
56
return (
57
57
/*Add your component below*/
58
-
<Ampligram style={styles.post}/>
58
+
<Ampligram style={styles.post}/>
59
59
);
60
60
}
61
61
conststyles= {
@@ -69,19 +69,19 @@ Here's how the code above would render in your app. *Some minor styling has been
69
69

70
70
71
71
### Using your component slot to replace individual child components
72
-
To use the component slot, pass a child component as a property of the parent component, using the prop name you picked earlier. Then, the content you pass will be rendered as a child of the component.
72
+
To use the component slot, pass a child component as a property of the parent component, using the prop name you picked earlier. Then, the content you pass will be rendered as a child of the component.
73
73
74
74
75
75
````jsx
76
-
import {
77
-
Ampligram
76
+
import {
77
+
Ampligram
78
78
} from'.ui-components'
79
79
80
80
functionApp() {
81
81
return (
82
82
<Ampligram style={styles.post} comments={
83
83
/* Pass your content into the component slot */
84
-
<div style={styles.comment}>
84
+
<div style={styles.comment}>
85
85
<h1>Hi mom!</h1>
86
86
<p>Thanks for checking out my app</p>
87
87
</div>
@@ -100,32 +100,32 @@ Here's how the code above would render in your app. *Some styling has been added
100
100

101
101
102
102
### Adding component slots to collections
103
-
Any component can be [converted to a collection](/console/uibuilder/collections/) and bound to data, and that includes components with component slots. With a collection, you can [extend your component via code](/console/uibuilder/override/) using the `overrideItems` prop to generate unique content within each component slot.
103
+
Any component can be [converted to a collection](/console/uibuilder/collections/) and bound to data, and that includes components with component slots. With a collection, you can [extend your component via code](/console/uibuilder/override/) using the `overrideItems` prop to generate unique content within each component slot.
104
104
105
-
Here, the Ampligram collection is mapped to a data model called Post. The Post model has a field called Comment, which contains an array of all the Comments associated with this Post. Each of these items in the Comment array is then mapped to the "comments" component slot you created.
105
+
Here, the Ampligram collection is mapped to a data model called Post. The Post model has a field called Comment, which contains an array of all the Comments associated with this Post. Each of these items in the Comment array is then mapped to the "comments" component slot you created.
106
106
107
-
Dynamically rendering child components is where component slots get very useful - you can even [pass another collection](/console/uibuilder/override/#nesting-collections) into this component slot.
107
+
Dynamically rendering child components is where component slots get very useful - you can even [pass another collection](/console/uibuilder/override/#nesting-collections) into this component slot.
108
108
109
109
<Calloutnote>
110
110
<strong>Limitation: Nested data fetching for many-to-many relationships</strong>
111
111
<p>
112
-
Automatic nested data fetching for many-to-many relationships is currently not supported. Currently, component slots only automatically fetches data for [has One](/cli/graphql/data-modeling/#has-one-relationship) and [has Many relationships](/cli/graphql/data-modeling/#has-many-relationship), like one Post to many Comments.
112
+
Automatic nested data fetching for many-to-many relationships is currently not supported. Currently, component slots only automatically fetches data for [has One](/cli/graphql/data-modeling/#has-one-relationship) and [has Many relationships](/cli/graphql/data-modeling/#has-many-relationship), like one Post to many Comments.
113
113
</p>
114
114
</Callout>
115
115
116
-
The code below will render an Ampligram for each Post in the AmpligramCollection. Then, the Comments for each Post will render in the "comments" component slot.
116
+
The code below will render an Ampligram for each Post in the AmpligramCollection. Then, the Comments for each Post will render in the "comments" component slot.
117
117
118
118
In this example, the first Post has 2 comments, but the second post has none.
0 commit comments