Web Components using AI
Last updated
Last updated
Here we have the docs necessary to build a custom web component using AI (ChatGPT) and add the HTML code into your Bravo Studio web component library. Additionally, you will be able to preview your web component in your app using our web-view Bravo Tag where your newly created web component will live.
Bravo Studio DEV
[component:web-view: URL] (You can see more about web views here).
Paid or Free Chat GPT account. (You can use any AI platform as far as it can create HTML code).
Bravo Vision DEV installed to test your app and web component.
Create an app page in Figma with a web view tag [component:web-view: URL] tag or you can copy our sample Figma file here.
Now that we have your Figma file ready, we can proceed to import to Bravo Studio.
Once imported, we can see our Bravo project and our web view page where we will be adding our web component.
Now that our app age is ready, we can ask AI to generate our web component code. In our example, we will generate a boxing timer.
This will be our initial prompt:
Im building a mobile app with Bravo Studio and i would like you to help me build a web component for a specific web view page inside my app. Its a boxing training app and i would like to add a boxing round timer. Please build it and include the following:
12 rounds of 3 minutes
Countdown timer
1 minute rest time between rounds
Round end warning when 10 seconds left to end each round.
Play a boxing bell sound to start the round, when 10 seconds left to end the round and when the round finishes.
Please style the timer with red colors and use old style squares typography like if it was an old alarm clock. Use neon style for the red color.
There should be a start button, a pause button and a reset button.
Chat GPT generates the code for us:
Heres the actual code if you wish to test the same:
Now that we can copied the code to our clipboard, we can go back to Bravo Studio. In our project page, let's move to the new project tab called “Components”.
Once in the components tab, hit the blue + button to create a new component in your components library.
After creating your web component, you will find a small code sample and a preview of how that looks as a webview on the right side. (You can even test changing the word hello in the code to see how it changes in our web component previewer. Make sure you press “Save” in order to see the changes).
Now that we have all set, lets copy the code that Chat GPT generated for our web component and paste it to our code editor. Make sure to first remove the sample data in it first by selecting all the text with Control + A and Delete. Once its all deleted, paste your web component code and press Save.
Now that we have added our code and press Save, you will see your code inside the code editor and the preview of our web component:
Remember, every code generated by Chat GPT will be different therefore you may want to adjust your initial prompt with follow up prompts till you get exactly what you are looking for. 💡TIP: If you want your web component to follow a specific design style, you can also include a screenshot of your app designed in Figma and instruct Chat GPT to respect your overall app design.
Feel free to test your newly generated web component inside the web component previewer:
Before we can test our web component on our phone using Bravo Vision, we must copy the URL link of our web component by pressing the Copy Link button under our code editor.
Once we have copied our web component unique URL, we must add it to our web-view Bravo Tag. For this example it looks like this:
[component:web-view: https://dev-bravo-apps-assets.s3.eu-central-1.amazonaws.com/U6QB112ECDKCBX5V6N2GGCWRGFYSG9A9F/01JGYQ60TF71JAGBXG53VDQBDX.html]
NOTE: You will need to copy your own link from the "Copy link" button.
🚨 Make sure to sync your Bravo project with Figma to make sure our Bravo project updates with the updated Bravo web-view Tag.
In Figma, we select our web-view Tag container name and replace it with the one above which includes the web component unique URL.
Now we can test our app and web component on our mobile device using Bravo Vision:
Duplicate the files below to see how to set it up!