- Podcasts
- CodingCat.dev Podcast
- Code with CodingCat.dev: Live Coding with the Amplify UI team
Code with CodingCat.dev: Live Coding with the Amplify UI team
CodingCat.dev Podcast
- June 30, 2024
- 1 h 30 min
- Episode 8
About this episodehttps://codingcat.dev/podcast/cwcc-0-8-amplify-ui
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Code with CodingCat.dev: Live Coding with the Amplify UI team
Hello everyone. Happy Friday. We've got the team from AWS Amplify with us today. Do we just want to do a quick like round Robin, kind of do an introduction? We'll stop start at my top right? Scott, you want to go first? Yeah, sure. So I'm Scott. I work as a front end engineer for the Amplify UI team.
Some of the things I enjoy doing would be sailing with my wife Mariah and playing with my two boys. Have a four year old and a 2 year old. Actually 5 year old now. He would be mad at me if I said 4. Nice. Heather, do you want to go? Sure. I'm also front engineer at Amazon. My name is Heather. I work on Scott's team at Amplify UI. I focus on UI accessibility.
I'm, I do a lot of stuff on the authenticator and authentication, you know, on our team. And I'm just a big fan of learning and teaching. I also have a YouTube channel which you can check out a program with Eric. And yeah, it's fun, fun to be on here and talk about Amplify. I have to know is there like a name behind your name plate with the the silver YouTube up there?
Yeah, that that's the program with Eric YouTube channel, so. It's awesome. That's really cool. I always forget the the colors. Was that 100,000? Yeah, that's 100,000. Congratulations, it's a lot of work to get to. Yeah, no kidding. Very cool. Well, I think what we're going to talk about today is all of the Amplify UI things that are happening right now. There was a big release that came up. Scott, you're, you're going to talk a little bit about that today.
Yeah. So we recently released the Amplify UI component library, which is a bunch of different React primitives as well as we also have connected components. But the the big release was making generally available all of the primitive components. Nice, is was that considered a one O release or is that more than that?
I think well we had previous. The package also contains the authenticators, so I think we're currently at 3.0. There was the previous version of the authenticator which our primitives are exported out of, but it was a major release. Nice. Very cool. Do you want to dive in and kind of show us more of that?
Yeah, absolutely. So just to kind of give you a little bit of background and just in case people don't know what Amplify is, I just want to briefly talk about what Amplify is and then we'll dig into kind of the UI side of things. That's probably a good, great place to start. Yeah, yeah. So Amplify is a set of front end tools for or a set of tools that allows front end web and mobile developers to quickly spin up and build full stack applications on AWS. So some of these tools people may be familiar with. There's Amplify Studio, which allows you to visually build a full stack app.
Amplify CLI allows you to spin up back end environments from your terminal. There's an Amplify hosting service that you can host static websites, and then there's a number of other like libraries that allow you to connect to different AWS services. So where we fit in that, like what is Amplify UI? So again, it's AUI component library that brings that simplicity of AWS Amplify to UI development. So some of the reasons you might want to use Amplify UI, we offer a bunch of different connected components. So the authenticator, which we'll be looking at a little bit later with Eric is an example of that. But the point of our cloud connected components is to simplify really complex workflows like authentication, connecting to like data stores, things like sync, things of that nature.
Another reason that you probably want to check out the Amplify UI components is because we built them to be very customizable and themeable. We kind of see this library is sitting in the middle of like the spectrum of UI libraries that are available. So on one hand, you have kind of headless UI frameworks like Radix and Headless UI, which really provide like functionality, but they don't provide any styling. Like you're supposed to bring your own styling. On the other side of the spectrum is something like MUI, which is sort of batteries included. The styling's already there.
Like there's some customization, but it's like sometimes difficult to like really get it customized maybe the way you want. So we're kind of in the middle because we allow you to like the CSS is imported separately and it's just CSS we're not using like a motion or something. So you can just leave the CSS out if you wanted to.
And you could completely restyle the authenticator or any of our components yourself while keeping all of that functionality that's available with the components. Or you can use our default theme. So we have a default theme, so they're already styled out-of-the-box. And then you can go and use one of our theming APIs or just CSS to change the theme to to what you want it to look like. So that's kind of why we see it sitting in the middle and kind of covering quite a broad range of use cases. I think in in the past there was there was always like Amplify UI components that covered like Angular and view and React Native and all of those is is this like a subset of that or is this kind of the next version that you guys are going with? Yeah.
The authenticator I believe was available for view and Angular in the past. Isn't that correct, Eric? Yep. Yes, it was. Yeah, we supported those in that. Yeah. So this is a the the authenticator was a rebuild cause of some of the styling problems that customers had with the previous version where it was hard to customize the styling.
We were using stencil and there was the shadow Dom was like making it hard to like customize the styling of the buttons and things. And so we rebuilt it to be very customizable and very themeable. So that was kind of the major change with the authenticator. But then while we were building the authenticator, we thought, well, we should build these primitive components or like these smaller pieces.
Very cool. Did you want to show off a little bit of kind of cool? Yeah. Share your screen. Yeah. So this way or this way is better, I never know. Yeah, No, I think it, I think it's good to show off the UI doc site. We worked really hard on it to make it show off. It's obviously built entirely with Amplify UI components and so we're pretty proud of it.
We have the cloud connected components and then we also have like pretty good integration with Amplify Studio. But I did want to talk a little bit about more about like what the primitive components are. So like that would be something like a card, an image. I'll actually come down here where there's like once you can click on.
So here you got like a, a switch. We've got pagination, you know, buttons, search all, all 40 different components like that. But kind of as I was talking about a little bit like this, the the approach that we took to the first styling for the web frameworks was to use plain CSS and also make them themeable via CSS variables.
So you can see here we've got like a style prop for direction, you know, font size large, large being one of our size design tokens that you can also customize. But then you get kind of that Intellisense in your in your editor. So that's a little bit about the the primitives and kind of some of the styling APIs that are available. I'll be demoing that a little bit more in a in a minute, but let's talk a little bit more about the connected components before we kind of dig into some code. So this is the authenticator.
The authenticator, as we kind of talked about, is this connect cloud connected component. And the real big benefit to it is you can just drop it into your application and get all these complicated authentication workflows that, you know, as developers, we may have implemented these many times in the past and they're like a pain in the neck.
And there's always like some edge case that you miss or you really just have to spend a ton of time like going through all of them. So you can drop this in. You now have, you know, with minimal configuration, you can have a sign in workflow, create account workflow, you know, forgot your password, all the things that you would expect.
And then you can also dig into more advanced features like multi factor auth or sign in with Facebook or sign in with Google. All the like Federated sign in stuff is also supported. So this gives you a way to get something going quickly, but then you have that full customization when you're ready to like make it more complicated from a functionality perspective.
But also the other thing that I'm sure all of us developers have run into is like, if OK, this is great, but this doesn't match my brand, right? Like that's a common problem as a developer. I've run into that many times in the past. This is fully themeable. Like like I said before, like don't include the CSS and then you could completely restyle it if you're if you want to go that extreme. Or you can use the default theme and like change the brand colors, change the sizes, the spacing, all of those things are customizable to get the look and feel that you want for the authenticator.
As as far as the authentication goes, typically you're on like the Amplify CLI and and creating that kind of package for lack of a better term. And cloud formation does its thing and sets up authentication. Is that the typical flow that a person running Amplify will usually do that and then kind of take these UI components and start adding them on, especially authenticator?
If you don't want to use the CLI, you could configure it there. But yeah, it's it you would use the Amplify to actually set up the like off back end using it'd be using Amazon Cognito. And and we have heard of some people using CDK, so you could even use the CDK to scaffold the back end and then use that with the amplify.
Yeah, I was doing a lot with Palumi for a little while, kind of tapping into it and then adding CDK on top of it. So it was, it was really nice flow to like get into and it'd be cool to, I know I was using like the legacy, if you call it that UI component for authentication and it worked really well. So I'm excited to to check this new one out. Awesome, nice, cool.
So you have like someones you would expect like a heading text divider. Like the reason that you would have a text primitive is because we Add all those styling APIs that you can use right on the component. Same with heading, just kind of makes it a little bit simpler. We have feedback components like a loader, you know, alert navigation, so links and tabs, a full set of input components for having a building forms and such.
And then there's layout components. So we have one that uses a a flex component that you can use to lay out using flexbox and grid and collections, which is actually kind of like a list. It just, and we'll see that one a little bit later with Heather's demo. And then there's, you know, data display and and kind of utility components. So that's enough just talking about what you can see on the dock site.
How about we dig into some actual code so that everyone doesn't fall asleep on me 'cause everyone likes to see code. You should be able to. OK, yeah, so so let's I'll just copy over my starting app. Here real quick. So I've kind of gone ahead and set up like a basic create React app. It's using TypeScript because I want to show off a a few features that you get if you have the types on the theme. But you know, everyone's familiar with setting up create React app.
And so we're going to build a little newsletter component for the perfect dev podcast here. So we need to like pull some of those brand colors in. I'm not gonna use the exact ones, but I've seen pink used quite a bit. So we're gonna use that for some of the buttons and some of the text. It's funny 'cause I can always say 5 E 1286 is our purple, but I can never remember our pink so. OK, well, I was gonna quiz you on that, but since you don't have that one memorized, we'll have to use the design tokens for people.
Great. So the first thing that you would do, I already have it installed, but let's just run it anyway. So you can kind of see the first thing that you would do would be add AWS Amplify UI React and the AWS Amplify peer dependency. That's for like the JavaScript libraries that we use under the covers.
So let's just run that. That's going to add those two dependencies there. So if we were pop open the package, Jason, you'll see we now have UI React version 3.4. And then we've also got AWS amplified down here. Great. So now I can uncomment these two lines because I had them commented out because they throw errors. A couple of things we're doing here. The main one here is we're importing the styles. This is giving us all the styling the for the default theme, and that will give us all the CSS variables as well, and we'll look at how to use those a little bit later. So you can see nothing's really changed yet. We're not using any components yet, but we do have the styling available to us.
So the first thing I'm going to do is just add a view. A view is really just a division, but it adds some of those theming APIs on top of it. So if I save that, not really much is going to change, but we've now got a division around that. The next thing I'm going to do, since we're building a newsletter component, is I'm going to just add a heading so that people know, hey, this is for signing up for the newsletter.
OK, there we go. All right, so now we've got a newsletter heading here. The default I believe is is a level 6. So it's an H6 right now. I happen to know that this is going to be a four on the app that I'm using. If I were, you know, I would probably re factor this out so that I could pass the level in.
But for now, we're just going to use level 4 so you can see it got a little bit bigger. So let's look at some of those styling props that I was talking about before. So I want to match the the brand colors here. So I'm going to use the color style prop and then I'm going to just start typing pink and you'll see you're already getting autocomplete. That's because our style props are aware of all of our design tokens that are in the default theme. So we have a set of colors.
I think Heather's gonna talk about them a little bit more, but we've got a different number of different pinks. I'm just gonna pick pink 80 here. So we saved that and now we've got some color. So we're starting to make some progress here. The next thing I'm gonna do is add like a text, a text component, and then just gonna copy and subscribe for all the latest updates. And this is basically just AP tag, as I mentioned before, but it does have all those styling props available to it. So we have Intellisense here.
It's going to give us a lot of the HTML things first. So I'm just going to change, I'm going to change the font style here and I'm going to make that italic. All right, So we're making a little progress here, but obviously a form's not all that interesting if you don't have. Well, actually I'll, I'll back, I'll back up just a minute.
Put that down here. Thank you, Prettier. And now we have centered newsletter component that's just 'cause it was bothering me, but it's also so we can talk about a few things on the view. So we've got a margin top of large. Large is again one of our design tokens that you can use. It's also customizable at the theme level. So if you wanted large to be enormous, it could be or you can adjust all those things.
We've got a margin in line. Oh, sorry, were you gonna say? Something I was just gonna ask if large is dependent on like device size or like window width. So it goes from like whatever 8 R.E.M. M to like two once you're on mobile or something like that. It's not, but that does kind of give me a chance to talk about the responsive style props because you could also do that.
So what we could do is say we want it to be large when it's at the base, like gotcha. At like at the base break point, which is kind of the small, the smaller break point. And then say maybe when you hit medium, you want it to be extra large. I think it's just XL. Is that right, Heather? Yeah, that's right.
So it should get a little bit bigger. You can see it bumps down once it hits that medium break point. So, and I think you actually you could change the spacing using our in the theme provider in in the theme object using overrides. You could use a media query in there and then actually change those design tokens.
OK, so let's go ahead and add some a text field and a button in here. So I'm going to start by adding a flex here and then I'm going to change the direction to column so that it's stacked and then I'm going to add in the text field. So the way that we built the the form components is we tried to take an approach where they're accessible by default. So rather than having to attach a label to a input and like do it that always remember that you have to put four on the label and you put the ID on the input.
And sometimes you get them confused and it doesn't quite work right. We thought, hey, why don't we just make that a little bit easier? Why is it saying that? I think I didn't import this. Oh yeah, OK, actually that's another thing. So, so I actually put the ID of of e-mail on here, but it's it's a little bit mad at me and we'll just look at why it's saying that the property label is missing.
So label is a required field. And the reason for that is because if you don't have label text, then we can't really put anything in the label. So let's add a label here of e-mail and let's go ahead and save that. So now you can see we've got text field showing on the page. If I click on the e-mail, you can see it's actually connected to the input field. So it's already been wired up.
So I'm going to say sign up on there. And then I'm going to make this a have a variation of primary since this is the primary action. So I'll go ahead and save that. So there's still one thing missing here, which is the color's still wrong. So the Button's a little bit different in terms of styling it because it's, you know, it's got a hover effect, it's got an active, you know, there's active hover focus.
So we're actually going to style that via the theme provider. So I'm going to import the theme provider and that'll give me a chance to show you about it, a few things about it. So put it up here. We'll wrap the whole app in it. So I'll pull that up and save that. You'll notice nothing's changed. And that's because we didn't override the theme. So if you don't override the theme, it's not going to do anything.
Sorry. So I'm gonna create a theme object here, and I'm actually gonna give it a type of theme. So I'll pull in theme TypeScript type, and that'll give us some nice intellisense on this. So the first thing that happens is I believe it's gonna start. Yeah, it's gonna start being mad at us 'cause we missed the name. So let's add Perfect Dev, Perfect, let's call it Perfect theme.
And then we can start adding some design tokens here. So we'll add the tokens. We want to customize the components. We want to change the button, we want to change the primary button. And then we're going to change the background color to the have a value of. And here I'm going to use one of our design tokens. So this will refer to those base design token color schemes. So I'm going to say colors dot pink .60. And then while we're here, I'm also going to change the hover. Oh, and I always forget this comma. Let's put the comma there and I'll change the background color for the hover colors dot pink .6. Actually I think this one's 80.
That way it's a little darker and I need. A quote. Nope, I missed something. Oh, I don't. I think there's one on the inside past the 80 there. Thank you. No worries. Yeah, I do like the new VS Code like colored curly braces though. That's been so helpful. OK, so nothing changed because I didn't pass it to the provider. Let's pass it to the provider and then let's go over here. And now we have a hover effect and a coloured the right branded colour button.
So yeah, Annie. Oh, actually I did have one more thing that I wanted to show you, which is the e-mail you'll notice actually already has the right colour. And that's because ha ha, ha, I already added some CSS that I didn't tell you about. This is just, I just wanted to show this off because it just shows how flexible our theming options are. Like sometimes you don't have to just use the theming props. You don't have to just use the theme provider. If you want to just write CSS, there's nothing stopping you from doing that.
So this this is targeting the Amplify text field class, which is going to surround this whole thing, including both the label and the input. And then we're targeting a specific CSS variable on the Amplify components field label color. And then we're actually assigning it to another one of our design tokens or CSS variables called Amplify colors pink.
So that kind of gives you a idea of the full spectrum of the theming options that are available. Nice. We we had a question come in, I think it was for the previous screen there if colours dot pink would work too. I'm not. Sure, if it's the class then instead of the object like broken out like that so. Heather's probably better at answering this question. Right.
Colors that pink won't work because we need to drill down to our scale. So in our design tokens that we're generating, they kind of work on this level where you have like a namespace. So that would be colors. And then we further section those out by the hue, which would be pink in this case. And then we use a range of colors. So I think there's 10 for each going from like 10 to 100. And then there's some like steps in between. So 10 refers to like the lightest color and then 100 would be like the darkest color.
And we have a section on our UI doc site which I can also show later, but that kind of shows like every default theme color we have to start with. Cool. Awesome. Thanks. Awesome, I think I can. That's all that I have for the demo with if you have any questions or Heather can take it on with the main demo. My only question that I have right now is like thinking about the amplified side of this in my head. Do these components like make it easier when you're taking in inputs to like update Dynamo through whatever on the Amplify side?
Or is it just kind of the normal way of taking in an input at that point? Yeah. So at the moment, that would just be the norm. It would be the normal way. You'd just have to connect directly. But that being said, these are the same components that the Figma and Studio use to generate code. So I don't know if you've looked at that at all, but the there's a capability in Amplify Studio where you can actually design these components.
Thought I could find one where. Oh yeah, here it is. So like you're inside of Figma, you generate like a design and Figma using our UI components. Like you can add a button, you can add a card, you can add an image, and then you pull that down into Amplify Studio and you can actually attach that to data and then export that down into your application as a component.
And it'll generate like readable real React code. Like you would write it using hooks to datastore and then and, and then you could use that with the theme provider. And if you had parts of your app that are completely custom, you could just keep using the UI primitives for the rest of those parts, or go through Figma. Yeah, that's really cool.
So we have this little mock up of like a properties listing app, kind of maybe like Airbnb type of clone kind of thing. So we have some cards to represent each property. And then we can see we have a header with our logo, we have a sign in button. So maybe we'll want to do something with routing and authentication, which Eric will show us a little bit later. And we also have some a color scheme on the side that our designer made, which happens to be being in this case. And you can see we have a little bit more like muted colors compared to the default UI.
going to want to build out some components to make these little card components. So if I hop over to where I'm going to start with, I just also scaffolded out a create React app. And there's a guide on our dock site like Scott mentioned that shows everything we do there, but pretty simple to get up and running.
And for me to start with, I set up some basic routes for us to work with. So our home page will be our properties listing and then I stubbed out like a login and admin page too. Very. Cool. And then just to see what else I added, so I added a react router so we can do a little bit of routing for the authentication. Also added in icons package, React icons has kind of like a, a conglomerate of a bunch of different icon libraries that I like to use.
And then since we're mostly going to focus on oh, hello, connections, we're going to mostly focus on building out UI components. So I just made some placeholder data like a JavaScript object. We were going to go the full like Amplify route. This is where you might go over to Amplify Studio and design out your data there.
Samplify Studios, kind of like our visual back end designer, where you can set up your schemas and all of your graph QL queries and things right from the an admin type of UI. But first we're just going to use some hard coded data to start with. Cool. So let's see, I think I'm going to start with building out just one of these cards, so like one property.
So I'll hop over to code and I also let me show I have the, the app running with just like some starter HTML elements just to save a little bit of time. So you can see I'm just like iterating through each property list. There's going to be some things we want to fix like these images are a little bit stretched out. So we'll we'll go over that.
Also also set up my header a little bit. So right now it's just unstyled, not using any of our components. So let's start with the property card. So I'll go down to my JSX here, and I know I probably want to have a link wrapping each card. Let me make some space. So I'm going to use our Amplify Link component.
And for now, we'll just have it keep linking back to the root, but probably you'd want to link it to like a detail page or something like that. And then let's fix our image components. So we're going to use the imply image component. All of these are just regular HTML or attributes that you'd have on a normal image element.
We kind of want it to sit next to this star rating component. So that's where I'll use that flexbox component that Scott showed. So we'll do flex and I drop these into there, reposition this so we can see. So the alignment's really weird right now. We'll fix that too by using some just layout rules that we can also pass as style props, Do a line item center and that fixes that layout. And then let's start restyling the heading. So I'll use heading component and I want mine to be in H2, so I'll do heading level 2 and the font size a little big right now.
We're actually going to fix that in our theme object instead just so we can show that off. So we'll we'll circle back to that and then we'll replace this rating value or it says 4 right here. We want that to be the star rating component. So we'll add that in and we'll make the value for that rating. On the image component, does that do any anything else like lazy load the images or anything? It, it does not.
I don't think we have any of that. Yeah. It's more just styling kind of like taking the basic image element and adding some properties to it for like utility. Let's see. So our rating component's really big right now. We want that to be small, so we'll just use a small variation And since this is actually a flex component like under the hood.
So if I. Look at rating. You can see it's picking up the Amplify Flex class. So we can apply flex layout rules to this component and it will also pick them up. So I can set a gap of let's do something kind of small. Well, and then I also want to align it to the right so it's always on the right no matter how short the title is. So let's do margin inline start.
So that's kind of a a cool thing I've learned recently. Let's see. And then we have some kind of like longer titles that are spilling over to two lines, like this one's really long, so let's make this actually truncated. It's just a prop we have for headings and we'll get true. So one line that's looking better, we'll come back and fix the color for our star rating object also.
But for now, let's move on to the beds. So at our mock up, oops, let's see what we have. We've got a little icon and then a little bit lighter Gray text. So that's where like Scott was showing off how to use the color style prompts. We can do that for there too. So I'm just gonna put this in another flex object just so I can align the icon with the text a little bit easier.
And I'm gonna pull in icon component. And this is pretty neat because, oops, let me spell that right. You can usually with like any SVG icon library. So we're using, I have box icons from that React icons package. So I'm going to use that and just do as icon. Now we have a little tiny bed icon showing up, which is what we want. And then again, I'm going to use some flex layout rules to center that vertically so we can see this a little better. And we also want to change the color to something a little bit lighter.
So we'll do color and then I'm going to do neutral, which is like our our Gray color scheme and we'll do neutral 80 should be pretty good. And then again, we can adjust those like gap properties. So it's a little bit closer. The text is a little closer to the icon. Great. And then the last thing for this is we just want to make this text color a little bit different so we can replace this with our text component is those. And we want the rating itself to be bold. So again, these are all tokens that we've defined in our our default theme.
So you could also do like thin or light or other font weights. Nice, are you able to set like font families on that too? Yes, you could theoretically go in and add a font family. So we have let me just show really quick on the doc site. If you go to default theme, you can go to topography and this shows some of the tokens. We still need to add a couple of the default tokens, but there's font weights, font sizes, there's line heights and then font families.
Cool. So let's see where we are. These are on 2 lines. You want them to be on one. So we're gonna make those a span by default. It's a paragraph tag. Change that. And then I think I want that that lighter color again. We'll copy this, add it there. Oh, so this is all using style props so far. And like Scott mentioned, there's a bunch of different ways that you can style amplify UI components. So I'm going to hop over and show like how we would do this, do some of the styling using the theme object. So if I go back here and I just have a file stubbed out to create my theme.
And again, I'm just importing the theme interface. So we get some nice TypeScript support, some nice auto complete. And here I'm going to just export a theme object and we'll do yelling at me because we're missing a name. So we'll do name. We'll let's do cabin theme. And I first I want to fix this heading size, which is kind of weird.
So we know we're going to update tokens. We'll drill into that and then go into components, then heading. And then I want to change heading level 2. Then we can do font size and then pass that of value. So here you could do something like 20 pixels, you could do like whatever you might use for like ACSS property rule. But we want to reference a design token 'cause we have like pretty extensive design token set up to start with. So we'll do font sizes.
Let's show, let's do large. We're not going to see it yet 'cause I haven't added it yet. So let's go over to our entry point. And here is where I can import that theme right there. And I'm already importing the theme providers. I'm just gonna wrap that around here, get you back in there, and then we can set our theme.
Looks like I'm missing something. Type string is not assignable. Curly braces. There we go cool. So now we can see our font sizes updated and our well, that's all we've changed so far as the font size. So let's go back over to theme 'cause we also wanted a different color for the star rating component. If we look at our mock up, got some kind of green colored stars there.
So let's add that here too. We can go into rating and well, one thing I'm going to do is I'm going to cheat a little bit. I'm going to grab all of these colors that match our color scheme. So we were modifying the tokens at a component level. We can also modify at that like base level, which is what you'd see like these are examples of like our very like base tokens. So let's add colors and we'll Add all of our color schemes in there and nothing's going to change too much because we're using a lot of like black and white and neutral colors right now.
Let's see. So we we changed our property card. I want to like deal with like the responsive layout now. So right now it's all just stacked into one row or one column. So if we go into our routes where I have my properties, so I already have a collection component set up. So Scott kind of mentioned this collection lets you pass it a list of items and kind of iterate through those with a component of your choosing. So for mine, I'm using that property card that we just made and that's how it's putting it into our our UI. And I want to adjust the column.
So you could also do type equals list, which makes it more of like a flexbox list. But I'm going to do type equals grid and then I can use some more like grid layout rules. So we have template columns already set up. I want to make this a little more responsive. So I'll pass it a responsive object and we can do, let's see, string actually Max 0 and we'll do up to 500 pixels so it can stretch down as small as it needs and then go up to 500 pixels. And then we can set a medium break point. And for that we want to repeat 2 columns. And we'll do min, Max zero and let it fill as much space as fits.
back here, make sure that everything's working. So we're missing something. I think it I think it does your two and then three if you go a little slower. Yeah, it looks like it's doing OK. Yeah, looks like we don't. Oh, I know what I missed. So let's go back to property card. I want to actually wrap these in a card element that will give us some of that like padding around them.
Yeah. Let's see, like card. Oh, that's better. And then one more small thing is we wanted to border radius on our image. Add that back in and we'll do medium there. There we go. Cool. And now we have our layout rules. And feel free to interrupt me if there's any other questions. Otherwise, we'll keep trucking through this.
Let's see. I want to like limit the width also. So right now it's stretching as much as it can. So we'll add a Max width, we'll do 1100 pixels and we'll do margin inline, gold auto so it centers it that way. We can restrict that a little bit. Nice. A couple more things that we'll we'll just clean up.
And I'm going to make this small variation O and then we can use some more layout rules. So we use, I use the flex component quite a bit. It's really handy for anything layout wise. We want to align these vertically. And then again, we'll do margin in line start holds auto so that our button will be all the way to the right. And then there were some other component styles I'm going to grab.
So right now our buttons still still styled like the default Amplify UI colors. So I'm just going to grab the rest of these that I had. So there's some styles in here for text inputs, and we'll just briefly look at those and then some styles for some of the other components that we're going to use too. So I'm going to take these and then I'm just going to pop these into my theme, my rating.
There we go. I think I might have already forgotten. Are you wrapping the whole thing in a theme provider as well? Right. So in the base of our app, because we want our entire app to pick to pick up our, our new theme. So we'll wrap the app at like the root level in the theme provider, and then that passes it down like all the context for it down to the rest of our components.
Cool. And like another thing, if once you add the theme provider, you can kind of see like how it adds the custom properties. So it provides this new division with a data attribute matching our theme. And then that's actually how it picks up the the new CSS custom properties that we're building with all of our our new theme overrides. Let's see, we had couple more things. So I'll go back to header want our cabin logo. So again, we could use icon component for that. And I'm going to load in my oops really braces my custom icon. And this is just an SVD that I have exported as a React component.
And we'll use that as our our logo. And I want this amplified cabins text to still be available for screen readers. So I'm going to wrap this in a visually hidden component. So this will still be in the Dom, still be available to assisted assisted technologies, but it won't be visually shown in the UI.
So I'm going to go in here, I'm going to change this to our grid element. I'm going to set the height to 100% and we want to use template rows and let's say we want the header to take up as much space as it needs, so we'll do auto and then we want the rest of the child or children components to fill the rest of the space. We'll do one Fr and we have a scroll view component where if the content inside of it is longer than its available space, it will let it overflow scroll.
So we'll put everything inside that. And here's where I'll show where we can add some little bit of extra utility CSS. So we don't often apply any CSS rules to the like body or root elements. So I just have some extra height 100 height 100% and overflow hidden. And if we go here now I can see that just our our properties area is scrollable.
Nice. Cool. I think that takes care of most everything. Let's see, we have a sign in route and right now that's blank because Eric's going to show us about the authenticator. And then we also had a admin UI page kind of just with some text inputs. And you saw where I added some of those other theme overrides. So we have some for buttons for the field controls which effects our text inputs.
So those are reflected in all these components that we added here. That's cool. Yeah, I think that's all I had for my demo. There's no questions. I can hand it over to Eric now. So I, I think we're, we're probably going to talk about this during Eric's, but I kind of want to throw this out there and you don't have to answer it right away, but why would someone like start to use the amplify UI components first, like a material UI or something else?
Is it, is it further integrated? I know like there's a slogan out there that says ready to connect to the cloud and it's like, oh, how's, how's that magic happen? Is that kind of the authenticator part and other additionals that that are coming out? Yeah. For me, I think it'd be if you want to use some things like the authenticator and some of the other cloud connected components that we have, because then you have kind of a design system to back up some of this other like more complicated functionality.
For me also I like the fact that I do have more flexibility for overriding the styling of components. So if I do want to use something like the authenticator, I have an easy way to make my components match my branding or color scheme or to build up my own components myself. So for me personally, like we were using a lot of style props for our like custom components that we made here, but I'd probably go through and let's see where's our property card.
You could even like take these out and refactor these into like your own class names to build up your own more complex, I guess primitive components. So like our card component itself right now it's pretty basic, but then you could use this to build up your own so it's a little more tailored to your own needs and. Solutions so you can make like an Alex card that would have all the styles that you just added to. Yeah.
Cool. Oh, totally makes sense. Thank you. Yeah, I would just add to that too, like the the connected components and theming the connected components is definitely a huge part of that. Like Heather's saying where you style the authenticator, now you can also style the rest of your app in the same way and have all of the styling in one place. But then there's that Figma integration that I was talking about earlier as well, where if there's like data connected components that you want to connect to data, and then you want the rest of your app to have the same components and use the same theme.
That Figma integration is using that same theme object. So you can actually in Figma change all your color schemes, all your spacing and and set all of those things in Figma So you can work with your designer on like what the styling is at that layer. And then when you import that into your app, now the rest of your components now have that branded. Look and feel.
Gotcha. Yeah, that's really cool. Awesome. Eric, do you want to finish up the authenticators? Sure, Sir. Are we good on time? Yeah, we're great. We have another 30 minutes, so take your time. All right, well, thanks. So yeah, I'm, I'm going to show it today how we can take Heather's design here, her app and add authentication into it. So we left off with the sign in button here. There's just authenticator goes here, there's nothing there. And so we want to add in a way for someone to log in and maybe have like some, we'll have some routes that are protected that can only be accessed by users that are authorized. So before we start, if you're following along at home, you can add in, you can add in the authenticator in our documents here.
If you go to Connected Components Authenticator, it shows you a quick start guide, but it's essentially you have to, you can install Amplify CLI and then you run this Amplify NIT command and Amplify add offs in the systems. You can, you have an AWS account already. If you don't, it's they have a generous free plan that you can check out and you can get into the AWS ecosystem.
But you can do this on the command line. Scott and Heather already mentioned Studio, which is a, a product that has more of a what you see what you get interface. You can just click on things and generate your back end really easily, including adding authentication through our Cognito service. You can do it that way.
And we even mentioned there's there's other ways of, of generating your back end. And when you do this, it creates the cloud formation script, cloud formation scripts that generate your back end. Then you would install this AW amplify UI React and AW amplifies or NPM install or yarn, and then you'll be all set.
So for the sake of time, I already did that here in this in this app here. And if we go and look at the side, you see there's an AWS exports file. So that has all the information we need for our application. It has where to connect to for our user pool through that's used with our Cognito service for authentication.
So let's see, let's let's just jump into the code here and see if we can get and authenticator working on this sign in Page. So first we need to do a little housekeeping. We need to we have this Amplify here. We need to import in that that AWS exports file, so we can print in from AWS exports. And then we need to do an amplify dot configure, which will then pass in the exports file. And then finally, because we're dealing with routes, there is a headless option.
So we want to really make the authenticator. We, we made the authenticator when we, when we did this last year, we made it very flexible and we made it to the point where you can really customize it. And so we had this headless usage option which allows us to get into the internals. We use something called X state to do our state management. So you can get into kind of the internals and get what route things are on and you can use it to really customize the experience when you're logging in. So we're going to to do that, you have to add this authenticator provider and you have to surround your app, all whole app by it.
So we'll go ahead and do that provider and then we'll just put this in here. Now the whole app is surrounded by authenticator provider. So now one last step. This was already added in here, but I added in this AW Amplify UI Rack styles. So this is going to add the styles for our authenticator, some default styles.
Otherwise it won't be completely unstyled, but we want to make sure that's in there too. OK, so let's go into the login and once again, we go back to our app. Here it says authenticator goes here. So that's not too helpful. So let's add in the authenticator. Sophie, you save it. So this is interesting, and nothing's showing up here.
And I think I know why. It's because I need to clear my cache 'cause I'm already logged in. Let's see here. Let's go to the application. Yeah, so I need to. I was doing a demo earlier and I was logged in, so we'll just clear that. There we go. OK, so here it is and that's just because I was already logged in the browser thought I was logged in and I didn't have anything.
Well, I'll show you guys here in a second what I mean. So here is the app. You can also notice that this looks a little different than the default app. If we go to the authenticator here, like this kind of has the this this light blue blue, greenish colors and this has like a darker green. That's because the styles that Heather already created are already being applied to the authenticator. And that's one of the reasons you may want to use our theme system and our components, because as you use our authenticator and our other connected components, it it's all ties into the same ecosystem. So it just kind of all fits together really nicely. And you can see here, we, we, we, these are the colors already put in.
You can even go even further. I added this in before the call or Heather added this in and added in like some border width for the router so you can use the theme object which I won't get into further. To even more customize this. You can even get rid of these tabs and make sure make it so only someone can log in and not log out or they can sign in but they can't create account. That is you can't always log out. And what I want to do here is I want so when it log, when you log in or sign in, anything between the opening and closing brackets of the authenticator will be displayed. So sometimes you'll see in simpler apps, you'll surround your whole application with the authenticator. So if you're creating like a dashboard and you only want authenticated or authorized people to to be in there, then you would surround your whole app by the authenticator. But since we have multiple routes here, we can just want to show it on this one login page.
Now once you login, I want to show a sign out button. So I'll do sign out here and I'll go ahead and use since we do have one, we'll use a button just from the UI, our UI React library. And then we also want it to sign out. So we'll we'll just do sign out and then we'll do an onclick and we'll pass sign out there.
Cool. So now we have this this sign out button that will only show after you log in. So let's create an account and let me give you like a quick tour. Scott mentioned a few of these things, but we can see it in action here. So by the way, when you use that Amplify CLI and you generate your authenticated back end, it's going to ask you some questions if you want to use sign in by e-mail or username or by phone. And I just chose the defaults, which was username, but you can certainly customize that if you want to use e-mail, which is pretty common.
So if you create a new account here you can go. I can put some information, I'm just using old e-mail address I have here and some put some test. And you can also notice as I was typing, it gives you a little bit of information like if you're doing it wrong because there is there is a certain restrictions and how you put the passwords in, which is configurable in Cognito.
And then yeah, here I'll put the e-mail address in. Now it's an old e-mail I have. And then I'll just put this in here. It's the username. So I'll click create create account here. And now it's it's emailing me, which I'll grab this code from another, another tab. You can't see right now because I'm logged into my e-mail and I'll put it in here.
And also if you forgot your password, you can click resend code. I'll click confirm. So it'll go ahead and log in. And now I just see a sign out button. But if you look underneath the covers and you go into your application tab, you can see that there is all these keys in here. So essentially, now you're completely logged in, you can use our JavaScript library to get your Jason web tokens, which are kind of ways to talk to our back end services.
Now you're kind of in the AP in the AWS ecosystem. So you can use this with the API Gateway and restrict access to certain routes or to certain Lambdas or your EC2 instances. So you're kind of in the ecosystem. You're authenticated and logged in at this point. And if you click log out, we're signed out.
And then you can always forget your password. It well, if you forget your password, you can click here. This is all built in and as we mentioned before you can do Federated sign in. Someone asked me the other day could I hook my existing out my existing Microsoft SAML based login system into Cognito and it's like, yes you can do Federated logins. You can set up your existing authorization systems with Cognito and it works with the with the authenticator here or our JavaScript library.
So now we kind of have a good idea of how this works. And of course you can do multi factor authentication. I've seen companies too where they don't let users sign up, so they create the accounts and the first time they log in it asks for the new password. We can do that. We can even set it up if you wanted to skip verification, you didn't want someone to enter a code in when they sign up.
Does that, Alex, does that sound good? Yeah, that sounds great. One thing that people I think that watch the show are used to doing like Firebase and things like that, would you mind jumping back into that config and just showing like the actual API key and like how that configuration is happening? Sure.
So in the, so in the what's it index TSX file right here, you you essentially once you configure through the Amplify init command that you install the CLI or you could do it through studio and then you rent Amplify add off, it generates this AWS exports file here. So just for folks listening, what that actually is doing like in AWS at that point, it's setting up that whole Cognito part and then this, this AWS exports piece, it's just a definition of those API keys coming back. Exactly.
Yep, that's the definition of where where all those keys are. And it creates the cloud formation scripts, which are, you know, infrastructure as code, so it knows how to generate the back end. You can easily delete the back end just from the command line, so it kind of does all that for you, which is great for front end developers.
Or or you're just trying to create a project and you don't want to have to write complicated cloud formation terraform, CDK scripts yourself. You can use tools like this that just auto generate it all. And the really cool part too, is that all three of you can be in the same project and you can pull down what's already up there in the Amplify side of things to your local and run it as well.
Excuse me? Yes, yeah, multiple environments. Yep. Yeah, totally. Let's let's check out one of those protected routes that we're going to show. OK, cool. All right, let's jump back into the login. All right, so in this login route, we're going to use this use Authenticator, which is gives us availability some some hooks that we can use to kind of dig into the eternals of our app.
So let's let's let's do that. I'm gonna grab this route and I'll make this a little bigger. I think that'll be easier to see. And this route will equal use authenticator. And then we have it's a little bit different syntax, but this is all inside the documentation. We have this context and we'll do this context dot route.
And this just says we're going to use this this route object, which changes when someone is authenticated or they're signed out or in their sign up or or sign in pages or wherever they're at. And then we're going to use this navigate, which is through the React router. And this is, by the way, this use authenticator was just imported in from UI React. So now we can do this use fact and we'll just do it. Just the easy if statement.
So someone can, you know, sign out after they do this? So. We're going to add in right here, and I already did. This is a lot of stuff that Heather already did. It's just a header at the top. So I'm going to once again grab some stuff out. We're going to add that route and sign out is used, use authenticator again, which I already have imported in.
And then we'll have this context context object which will return a context dot route and a context dot sign out. And that's just kind of the syntax we use for these kind of headless hooks that we're, we're going to use. And then we'll add right here a sign out. And right now all we have is this view here with this button that says sign in. So right under here, I'm going to add in a right route equal equals authenticated.
and then for here, and it's giving me an error because I need to move this up and I'll move this in here. OK, All right, so you see it's changed to sign out now. So I think it's already working. So notice that I'm authenticated and now it's letting me fix it. So if I click sign out, it's sign out. And you can see here I need to do one other thing, go back to the login.
And just to be clear, this is just protecting it on the client side. If you were doing this in production, you really need to protect it on the server side. So any kind of back end end points you need to probably put behind like an API gateway or have some authentication authorization rules in place. Otherwise people could just probably get into it because you never trust the client.
It's a great reminder. People forget that all the time. All. Right, so to to protect this route, I'm going to go to our app TSX file and right here, this is the admin route. You see, there's nothing really special here. So I'm kind of acting like a, a route card, but this is really, I'm using AI already did this beforehand just to save time. This is really looking at our use authenticator using that route and then navigating to this. So this is just a real simple way to change the navigation depending on if users authenticated or not. And so I I wrote this earlier and so that should be we can just use this require auth component and surround it. And this is also very similar if you look at the rack router documentation on how to create protected routes. So I stole some inspiration from there. So we just do require us here.
We'll put the edit property in the middle and that should be it. So let's see if it works. So if we go up here and we do admin, so it redirected to login. So it didn't show the route as which is the right thing it should do. So it's redirects to login. Now if we login, we just make sure this didn't break and that you can get to the admin route.
And is it thinking is it signs in cool? So it's still logging into the admin route. And then at this point we would, we could fill out all this information, we click save property, hit our external endpoints in our AWS ecosystem and be protected and and we would be all set from there. So that's all I have to show on this. Nice.
You want to talk about that, Eric? Or I could, yeah. So the question is what sort of real time features we have? Just in general like what what people use AWS Amplify for? Yeah, I mean, they use it for all sorts of things. Like a lot of the, the use case I just showed for the authenticator is pretty common.
A lot of people use this authenticator and it's for to remind everyone again, it's for not just React, but for you view and Angular and and we have Flutter and and we're supporting more and more of these frameworks and libraries all the time. But it's also really used a lot with our AWS JavaScript amplify library.
And that library allows you to connect to Datastore app sync is is really important. So it's almost like our manage graph QL interface. And we have tools like Datastore that are similar to like Firestore where you can quickly like update data in real time. There's subscriptions that you can do with our App Sync service.
So you don't have to set up web sockets or anything. Data will just automatically get updated all the time. We have S3 tools that connect to our, not really real time, but it would you can connect to S3 buckets. So yeah, there's quite a quite a few people things people use it from large, from small start-ups and just need to get up and running really quickly or with AW ecosystem to, to even larger companies. And then we give hooks and ways in the background where you can, would you say Scott eject from our amplified ecosystem at some point if you need to and and kind of and keep going with with what you want.
Yeah. I mean, we have like capabilities where you can add CDK. So if there's like something that's not available in Amplify, then you can add a CDK. You can use CDK to kind of attach that when you deploy and then it'll deploy those resources as well. So there's a lot of flexibility there. And it kind of extends out all the way through the AWS like ecosystem after that, right?
Like you can write your own Lambdas and kind of put those through all that sort of stuff. Yeah, exactly. Yeah, it's just connected right in. Nice. We may have lost Scott. I don't know. Or not Scott. Sorry, Eric. What happened there? Yeah. So, yeah. So I would also just say like, we're in open source library and we treat feature requests really seriously.
So I'd encourage everyone to just check it out, play around with it, play with the authenticator, the UI components, some of the other Amplify features. And just let us know, you know, if, if there's a component that we're missing that you're really interested in, tell us that because we're, we're currently working on more connected components and we just want to make this just make it easier for developers to build UIS that connect to the cloud.
I think you guys should like get with the Kendo UI folks and just like talk about table design and like go to town on it. It would be great. Sounds good. Awesome. Well, thank you guys so much for like giving me a full tour of all the new AWS Amplify UI components. It it sounds like even though like you're far along, there's probably a lot more that's going to continue since you have this base now.
We we want to to add more components that just make things easier for, for developers and take, take away some of those really complex workflows, but then also try to make them as flexible and customizable and themeable as possible. That's kind of our goal. And and also just make things smaller, faster, better. I think that's just taking what we have already and just making it that much easier for developers to use. And that's exactly we've been looking at that as well. You had mentioned before you used to use Stencil to kind of create the different frameworks or or use it in the different frameworks.
Is there something you use today to to be able to create those across like Angular, React, Flutter? So, so we ran into a lot of problems with Stencil, in particular around customization, where like for example, the authenticator, you actually couldn't when it, when it was in Stencil, you couldn't access it via password managers.
So password managers couldn't see the fields because they were in the shadow Dom. So there's, you know, a lot of limitations I think with web components in that regard in terms of like tooling to generate components. The the the philosophy that we took there is we really want to respect each framework for what it does and what it does well.
So rather than auto generating components and maybe ending up with AP is that don't make quite as much sense. The approach that we want to take is to build a React component that feels like a React component to build, you know, a view component that feels like a view component. And so as much as possible, we want to make AP is consistent across frameworks, but at the same time, we don't want to do things that are like unnatural for that particular framework.
So, and for that reason, we really feel like it makes more sense for our goals with the UI framework to to write them as that, as that in that framework using kind of the paradigms and naming standards and all of that. Gotcha, Very cool. Probably my last question for you all, is this open source and how can people get involved to help? Absolutely, yeah, it's a open source, I believe it's Apache two licensed.
We have GitHub if you just search for Amplify UII think it's like the 2nd result and we'd love to hear, you know, feedback, feature requests, bugs, contributions. There's a lot of contributors the that help us, especially around docs issues, but we're also working with a few contributors on some some other features as well, like on our map component. Sweet, that sounds awesome.
