Samples / Controls / sap.ui.core

Icon

Built with an embedded font, icons scale well, and can be altered with CSS. They can also fire a press event. See the Icon Explorer for more icons.

Class
z2ui5_cl_smpc_app_122
Repository
abap2UI5/samples-controls
Ports
sap.ui.core.sample.Icon
UI5 libraries
sap.m, sap.ui.core
Lowest UI5 release
1.71
In the browser
Runs in the playground
Controls it builds
sap.m.FlexItemData, sap.m.HBox, sap.ui.core.HTML, sap.ui.core.Icon, sap.ui.core.mvc.View

The class

" @keywords icon sap.ui.core font gallery html hbox flexitemdata
" @summary Built with an embedded font, icons scale well, and can be altered with CSS. They can also fire a press event. See the Icon Explorer for more icons.
" @origin sap.ui.core.sample.Icon - https://sdk.openui5.org/entity/sap.ui.core.Icon/sample/sap.ui.core.sample.Icon (status: reviewed - read against the original, not run)
CLASS z2ui5_cl_smpc_app_122 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

  PROTECTED SECTION.
    DATA client TYPE REF TO z2ui5_if_client.

    METHODS view_display.

  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smpc_app_122 IMPLEMENTATION.

  METHOD z2ui5_if_app~main.

    me->client = client.
    IF client->check_on_navigated( ).
      view_display( ).
    ENDIF.

  ENDMETHOD.


  METHOD view_display.

    DATA(view) = z2ui5_cl_ui5_view_builder=>factory( ).

    view->ele( n = `View` ns = `mvc`
        )->a( n = `xmlns:core` v = `sap.ui.core`
        )->a( n = `xmlns:mvc`  v = `sap.ui.core.mvc`
        )->a( n = `xmlns`      v = `sap.m`

        " the sample's style.css, injected via a core:HTML content attribute
        " (see CAPABILITIES.md) - the five size classes the Icons below carry,
        " including the <600px media query, verbatim. Literal braces are escaped
        " \{ \} in a backtick literal: the XMLView parser reads an unescaped
        " brace as a binding
        )->tag( n = `HTML` ns = `core`
            )->a( n = `content` v = `<style>` &&
                                    `.size1\{font-size:1.5rem\}` &&
                                    `.size2\{font-size:2.5rem\}` &&
                                    `.size3\{font-size:5rem\}` &&
                                    `.size4\{font-size:7.5rem\}` &&
                                    `.size5\{font-size:10rem\}` &&
                                    `@media (max-width:599px)\{` &&
                                    `.size1\{font-size:1rem\}` &&
                                    `.size2\{font-size:2rem\}` &&
                                    `.size3\{font-size:3rem\}` &&
                                    `.size4\{font-size:4rem\}` &&
                                    `.size5\{font-size:5rem\}\}` &&
                                    `</style>`

        )->ele( `HBox`
            )->a( n = `class` v = `sapUiSmallMargin`

            )->ele( n = `Icon` ns = `core`
                )->a( n = `src`   v = `sap-icon://syringe`
                )->a( n = `class` v = `size1`
                )->a( n = `color` v = `#031E48`
                )->ele( n = `layoutData` ns = `core`
                    )->tag( `FlexItemData`
                        )->a( n = `growFactor` v = `1`

                )->end(
            )->end(

            )->ele( n = `Icon` ns = `core`
                )->a( n = `src`   v = `sap-icon://pharmacy`
                )->a( n = `class` v = `size2`
                )->a( n = `color` v = `#64E4CE`
                )->ele( n = `layoutData` ns = `core`
                    )->tag( `FlexItemData`
                        )->a( n = `growFactor` v = `1`

                )->end(
            )->end(

            )->ele( n = `Icon` ns = `core`
                )->a( n = `src`   v = `sap-icon://electrocardiogram`
                )->a( n = `class` v = `size3`
                )->a( n = `color` v = `#E69A17`
                )->ele( n = `layoutData` ns = `core`
                    )->tag( `FlexItemData`
                        )->a( n = `growFactor` v = `1`

                )->end(
            )->end(

            )->ele( n = `Icon` ns = `core`
                )->a( n = `src`   v = `sap-icon://doctor`
                )->a( n = `class` v = `size4`
                )->a( n = `color` v = `#1C4C98`
                )->ele( n = `layoutData` ns = `core`
                    )->tag( `FlexItemData`
                        )->a( n = `growFactor` v = `1`

                )->end(
            )->end(

            )->ele( n = `Icon` ns = `core`
                )->a( n = `src`   v = `sap-icon://stethoscope`
                )->a( n = `class` v = `size5`
                )->a( n = `color` v = `#8875E7`
                )->a( n = `press` v = client->follow_up_action( val = client->cs_event-control_global t_arg = VALUE #( ( `MESSAGE_TOAST` ) ( `show` ) ( `Over budget!` ) ) )
                )->ele( n = `layoutData` ns = `core`
                    )->tag( `FlexItemData`
                        )->a( n = `growFactor` v = `1` ).

    client->view_display( view->stringify( ) ).

  ENDMETHOD.

ENDCLASS.