See all 3 parts of the custom component series:
Both the tooltip and Fiori dialog are available for use now. |
We started by taking a blank project and adding the following components:
Select the icon component and change the icon to display the information Fiori icon.
For the inner container, set the spacing:
For the Text component, we need to also set the width to Custom, and select Fit Content and minimum of 150 pixels and maximum to 250 pixels. The height should be Grow to height.
And we need to bind the Text component's Content property to our custom component's Text property, so developers can set the text.
The property appears under Composite component internal property.
You can also set the color of the icon, text container, and text.
Now we want the tooltip to appear when the user clicks the icon, and disappear on another click. We will also make the text disappear automatically after 5 seconds.
In the Component Template Editor for the custom component, add a set private variable flow function, and set our ShowInfo private variable to a formula to toggle its state:
!privateVars.ShowInfo
You can now save the project and test the component. If you click the icon, you should see the tooltip with default text.
Let's add the feature to automatically hide the tooltip after 5 seconds. We add the following:
The component you created is under the By Me tab (where the components are shown), which shows the custom components you have modified. This new component will only be in your project. If you want to share or reuse, click the 3 dots and select Publish to marketplace.
Then select Publish New. This makes it available to any user in your BTP landscape (e.g., eu10).
You will get an alert with the token for finding your component in the marketplace. Save this token.
The component is now removed from the By Me tab and moved to the Installed tab.
The component can be found in your subaccount by searching for the title or description. Any other user in the BTP landscape will need the token.
Let's say we had a UI with 2 buttons and we wanted to put the tooltip in the middle.
We can click on Marketplace.
Enter the token, and the component is displayed.
Click on the component, and click Install. It will be in the Installed tab.
Now drag a copy of the component between the buttons.
With the tooltip selected, in the Properties tab, add some text. I added this using a formula (if you add as plain text, the slashes will be escaped). You can use the Unicode characters to add spacing or special characters.
"This is the first line of the tooltip. \u000A\u000A This is the second line of the tooltip."
If you preview the app, you will see that it creates a lot of extra space, and the tooltip is masked by the container in the app.
So you must do the following:
And now run the app again, and click the icon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.