diff --git a/en/application-dev/reference/arkui-ts/figures/gauge-image.png b/en/application-dev/reference/arkui-ts/figures/gauge-image.png new file mode 100644 index 0000000000000000000000000000000000000000..d8fa99c3cc70ca08914a3850d95d2511eff923cd Binary files /dev/null and b/en/application-dev/reference/arkui-ts/figures/gauge-image.png differ diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md index 291b5d3273c6f71649c679b962232780b7b0b68e..5b4387a8c137fd14e9866238aef6785300f93918 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -21,19 +21,21 @@ Gauge(options:{value: number, min?: number, max?: number}) | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| value | number | Yes| Current data value.| +| value | number | Yes| Current value of the chart, that is, the position to which the pointer points in the chart. It is used as the initial value of the chart when the component is created.| | min | number | No| Minimum value of the current data segment.
Default value: **0**| | max | number | No| Maximum value of the current data segment.
Default value: **100**| ## Attributes +In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. + | Name| Type| Description| | -------- | -------- | -------- | -| value | number | Value of the chart.
Default value: **0**| -| startAngle | number | Start angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **-150**| -| endAngle | number | End angle of the chart. The value 0 indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **150**| -| colors | Array<ColorStop> | Colors of the chart. Colors can be set for individual segments.| -| strokeWidth | [Length](ts-types.md#length) | Stroke width of the chart.| +| value | number | Value of the chart. It can be dynamically changed.
Default value: **0**| +| startAngle | number | Start angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **0**| +| endAngle | number | End angle of the chart. The value **0** indicates 0 degrees, and a positive value indicates the clockwise direction.
Default value: **360**| +| colors | Array<[ColorStop](#colorstop)> | Colors of the chart. Colors can be set for individual segments.| +| strokeWidth | Length | Stroke width of the chart.| ## ColorStop @@ -41,7 +43,7 @@ Describes a gradient stop. | Name | Type | Description | | --------- | -------------------- | ------------------------------------------------------------ | -| ColorStop | [[ResourceColor](ts-types.md#resourcecolor8), number] | Type of the gradient stop. The first parameter specifies the color, and the second parameter specifies the offset, which ranges from 0 to 1.| +| ColorStop | [[ResourceColor](ts-types.md#resourcecolor), number] | Type of the gradient stop. The first parameter indicates the color value. If it is set to a non-color value, the black color is used. The second parameter indicates the color weight. If it is set to a negative number or a non-numeric value, the color weight is 0, which means that the color is not displayed.| ## Example @@ -53,15 +55,30 @@ Describes a gradient stop. @Component struct GaugeExample { build() { - Column() { - Gauge({ value: 50, min: 0, max: 100 }) - .startAngle(210).endAngle(150) - .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]) - .strokeWidth(20) + Column({ space: 20 }) { + // Use the default value of min and max, which is 0-100, and the default values of startAngle and endAngle, which are 0 and 360, respectively. + // Set the current value to 75. + Gauge({ value: 75 }) .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // Set the value parameter to 75 and the value attribute to 25. The attribute setting is used. + Gauge({ value: 75 }) + .value(25) // If both the attribute and parameter are set, the parameter setting is used. + .width(200).height(200) + .colors([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1]]) + + // A ring chart of 210 to 150 degrees + Gauge({ value: 30, min: 0, max: 100 }) + .startAngle(210) + .endAngle(150) + .colors([[0x317AF7, 0.1], [0x5BA854, 0.2], [0xE08C3A, 0.3], [0x9C554B, 0.4]]) + .strokeWidth(20) + .width(200) + .height(200) }.width('100%').margin({ top: 5 }) } } ``` -![en-us_image_0000001174422916](figures/en-us_image_0000001174422916.png) +![gauge](figures/gauge-image.png) diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md index b88b175789c9aa37e06ff27c24072a68ecb4badf..4d653819c3a3a07fc0951112740075e72d8dc2c3 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -23,7 +23,7 @@ Image(src: string | PixelMap | Resource) | Name| Type | Mandatory| Default Value| Description | | ------ | ------------------------------------------------------------ | ---- | ------ | ------------------------------------------------------------ | -| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](ts-types.md#resource) | Yes | - | Image source. Both local and online images are supported.
When using resources referenced using a relative path, for example, `Image("common/test.jpg")`, the **\** component cannot be called across bundles or modules. Therefore, you are advised to use `$r` to reference image resources that need to be used globally.
- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.
\- Base64 strings are supported. The value format is `data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, where `[base64 data]` is a Base64 string.
\- The value can also be a path starting with `dataability://`, which is used to access the image path provided by a Data ability.
\- Strings with the `file:///data/storage` prefix are supported, which are used to read image resources in the` files` folder in the installation directory of the application. Using such strings requires read permission on the files in the installation directory. | +| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7)\| [Resource](ts-types.md#resource) | Yes | - | Image source. Both local and online images are supported.
When using resources referenced using a relative path, for example, `Image("common/test.jpg")`, the **\** component cannot be called across bundles or modules. Therefore, you are advised to use `$r` to reference image resources that need to be used globally.
- The following image formats are supported: PNG, JPG, BMP, SVG, GIF.
\- Base64 strings are supported. The value format is `data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, where `[base64 data]` is a Base64 string.
\- The value can also be a path starting with `dataability://`, which is used to access the image path provided by a Data ability.
\- Strings with the `file:///data/storage` prefix are supported, which are used to read image resources in the` files` folder in the installation directory of the application. Using such strings requires the read permission on the files in the installation directory.| ## Attributes @@ -31,10 +31,10 @@ Image(src: string | PixelMap | Resource) | --------------------- | ---------------------------------------- | -------- | ---------------------------------------- | | alt | string \| [Resource](ts-types.md#resource) | - | Placeholder image displayed during loading. Only local images are supported. | | objectFit | [ImageFit](ts-appendix-enums.md#imagefit) | Cover | Image scale mode. | -| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | NoRepeat | Whether the image is repeated.
> **NOTE**
> This attribute is not applicable to SVG images.| -| interpolation | ImageInterpolation | None | Interpolation effect of the image. This attribute is intended to alleviate aliasing that occurs when a low-definition image is zoomed in.
> **NOTE**
> This attribute is not applicable to SVG images or **PixelMap** objects. | -| renderMode | ImageRenderMode | Original | Rendering mode of the image.
> **NOTE**
> This attribute is not applicable to SVG images.| -| sourceSize | {
width: number,
height: number
} | - | Decoding size of the image. The original image is decoded into an image of the specified size. If the value is of the number type, the unit px is used.
> **NOTE**
> This attribute is not applicable to **PixelMap** objects.| +| objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | NoRepeat | Whether the image is repeated.
**NOTE**
This attribute is not applicable to SVG images. | +| interpolation | ImageInterpolation | None | Interpolation effect of the image. This attribute is intended to alleviate aliasing that occurs when a low-definition image is zoomed in.
**NOTE**
This attribute is not applicable to SVG images or **PixelMap** objects. | +| renderMode | ImageRenderMode | Original | Rendering mode of the image.
**NOTE**
This attribute is not applicable to SVG images. | +| sourceSize | {
width: number,
height: number
} | - | Decoding size of the image. The original image is decoded into an image of the specified size. If the value is of the number type, the unit px is used.
**NOTE**
This attribute is not applicable to **PixelMap** objects. | | matchTextDirection | boolean | false | Whether to display the image in the system language direction. When this parameter is set to true, the image is horizontally flipped in the right-to-left (RTL) language context. | | fitOriginalSize | boolean | true | Whether to fit the component to the original size of the image source when the component size is not set. | | fillColor | [ResourceColor](ts-types.md#resourcecolor8) | - | Fill color of the image. This attribute only applies to an SVG image. Once set, the fill color will replace that of the SVG image. | @@ -308,7 +308,7 @@ struct LoadImageExample { this.path = EMPTY_PATH; this.path += getContext(this.bundleCodeDir + '/entry/resource/base/media/icon.png'); }) - Text(`Image path: ${this.path}`) + Text(`Image pth: ${this.path}`) .fontSize(20) .margin({ bottom: 10 }) Image(this.path) diff --git a/en/application-dev/ui/js-framework-syntax-css.md b/en/application-dev/ui/js-framework-syntax-css.md index 46fcc170df8f4688da555b6874a6842c1c6806e8..ddc1d07b3467afee3eca85caa2031347d87307e1 100644 --- a/en/application-dev/ui/js-framework-syntax-css.md +++ b/en/application-dev/ui/js-framework-syntax-css.md @@ -1,28 +1,27 @@ # CSS - Cascading Style Sheets (CSS) is a language used to describe the HML page structure. All HML components have default styles. You can customize styles for these components using CSS to design various pages. For details, see [Universal Styles](../reference/arkui-js/js-components-common-styles.md). ## Size Unit -- Logical px set by \: - - The default logical screen width is 720 px (for details, see the "window" section in [config.json](js-framework-js-tag.md)). Your page will be scaled to fit the actual width of the screen. For example, on a screen with the actual width of 1440 physical px, 100 px is displayed on 200 physical px, with all sizes doubled from 720 px to 1440 px. - - If you set autoDesignWidth to true (for details, see the "window" section in [config.json](js-framework-js-tag.md)), the logical px are scaled based on the screen density. For example, if the screen density is 3x, 100 px will be rendered on 300 physical px. This approach is recommended when your application needs to adapt to multiple devices. +- Logical px set by **\**: + + - The default logical screen width is 720 px (for details, see the **"window"** section in **[config.json](js-framework-js-tag.md)**). Your page will be scaled to fit the actual width of the screen. For example, on a screen with the actual width of 1440 physical px, 100 px is displayed on 200 physical px, with all sizes doubled from 720 px to 1440 px. + - If you set **autoDesignWidth** to **true** (for details, see the **"window"** section in **[config.json](js-framework-js-tag.md)**), the logical px are scaled based on the screen density. For example, if the screen density is 3x, 100 px will be rendered on 300 physical px. This approach is recommended when your application needs to adapt to multiple devices. -- Percentage set by <percentage>: The component size is represented by its percentage of the parent component size. For example, if the width <percentage> of a component is set to 50%, the width of the component is half of its parent component's width. +- Percentage set by **\**: The component size is represented by its percentage of the parent component size. For example, if the width **\** of a component is set to **50%**, the width of the component is half of its parent component's width. ## Style Import -CSS files can be imported using the @import statement. This facilitates module management and code reuse. +CSS files can be imported using the **@import** statement. This facilitates module management and code reuse. ## Style Declaration -The .css file with the same name as the .hml file in each page directory describes the styles of components on the HML page, determining how the components will be displayed. +The **.css** file with the same name as the **.hml** file in each page directory describes the styles of components on the HML page, determining how the components will be displayed. -1. Internal style: The style and class attributes can be used to specify the component style. Example: - +1. Internal style: The **style** and **class** attributes can be used to specify the component style. Example: ```html
@@ -30,7 +29,6 @@ The .css file with the same name as the .hml file in each page directory describ
``` - ```css /* index.css */ .container { @@ -38,8 +36,7 @@ The .css file with the same name as the .hml file in each page directory describ } ``` -2. External style files: You need to import the files. For example, create a style.css file in the common directory and import the file at the beginning of index.css. - +2. External style files: You need to import the files. For example, create a **style.css** file in the **common** directory and import the file at the beginning of **index.css**. ```css /* style.css */ .title { @@ -47,7 +44,6 @@ The .css file with the same name as the .hml file in each page directory describ } ``` - ```css /* index.css */ @import '../../common/style.css'; @@ -61,19 +57,18 @@ The .css file with the same name as the .hml file in each page directory describ A CSS selector is used to select elements for which styles need to be added to. The following table lists the supported selectors. -| Selector | Example | Description | -| -------- | -------- | -------- | -| .class | .container | Selects all components whose class is container. | -| \#id | \#titleId | Selects all components whose id is titleId. | -| tag | text | Selects all <text> components. | -| , | .title, .content | Selects all components whose class is title or content. | -| \#id .class tag | \#containerId .content text | Selects all grandchild **\** components whose grandparent components are identified as containerId and whose parent components are of the content class. To select child components, use > to replace the space between **\#id** and **.class**, for example, **\#containerId>.content**. | - -The following is an example: +| Selector | Example | Description | +| ------------------------- | ------------------------------------- | ---------------------------------------- | +| .class | .container | Selects all components whose **class** is **container**. | +| \#id | \#titleId | Selects all components whose **id** is **titleId**. | +| tag | text | Selects all **\** components. | +| , | .title, .content | Selects all components whose **class** is **title** or **content**. | +| \#id .class tag | \#containerId .content text | Selects all grandchild **\** components whose grandparent components are identified as **containerId** and whose parent components are of the **content** class. To select child components, use **>** to replace the space between **\#id** and **.class**, for example, **\#containerId>.content**.| +Example: ```html - +
Title
@@ -82,18 +77,17 @@ The following is an example:
``` - ```css -/* Page style xxx.css */ +/* Pagestyleexample.css */ /* Set the style for all
components. */ div { flex-direction: column; } -/* Set the style for the component whose class is title.*/ +/* Set the style for the components whose class is title. */ .title { font-size: 30px; } -/* Set the style for the component whose id is contentId. */ +/* Set the style for the components whose id is contentId. */ #contentId { font-size: 20px; } @@ -101,11 +95,11 @@ div { .title, .content { padding: 5px; } -/* Set the style for all texts of components whose class is container.*/ +/* Set the style for all texts of components whose class is container. */ .container text { - color: \#007dff; + color: #007dff; } -/* Set the style for direct descendant texts of components whose class is container.*/ +/* Set the style for direct descendant texts of components whose class is container. */ .container > text { color: #fa2a2d; } @@ -115,31 +109,29 @@ The above style works as follows: ![en-us_image_0000001267607889](figures/en-us_image_0000001267607889.png) -In the preceding example, .container text sets title and content to blue, and .container > text sets title to red. The two styles have the same priority, but .container > text declares the style later and overwrites the former style. (For details about the priority, see [Selector Specificity](#selector-specificity).) +In the preceding example, **.container text** sets title and content to blue, and **.container > text** sets title to red. The two styles have the same priority, but **.container > text** declares the style later and overwrites the former style. For details about the priority, see [Selector Specificity](#selector-specificity). ## Selector Specificity -The specificity rule of the selectors complies with the W3C rule, which is only available for inline styles, id, class, tag, grandchild components, and child components. (Inline styles are those declared in the style attribute.) +The specificity rule of the selectors complies with the W3C rule, which is only available for inline styles, **id**, **class**, **tag**, grandchild components, and child components. (Inline styles are those declared in the **style** attribute.) -When multiple selectors point to the same element, their priorities are as follows (in descending order): inline style > id > class > tag. +When multiple selectors point to the same element, their priorities are as follows (in descending order): inline style > **id** > **class** > **tag**. ## Pseudo-classes -A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). For example, :disabled can be used to select the element whose disabled attribute is true. - -In addition to a single pseudo-class, a combination of pseudo-classes is supported. For example, :focus:checked selects the element whose focus and checked attributes are both set to true. The following table lists the supported single pseudo-class in descending order of priority. - +A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected elements. For example, **:disabled** can be used to select the element whose **disabled** attribute is **true**. -| Pseudo-class | Available Components | Description | -| -------- | -------- | -------- | -| :disabled | Components that support the disabled attribute | Selects the element whose disabled attribute is changed to true (unavailable for animation attributes). | -| :active | Components that support the click event | Selects the element activated by a user. For example, a pressed button or a selected tab-bar (unavailable for animation attributes). | -| :waiting | button | Selects the element whose waiting attribute is true (unavailable for animation attributes). | -| :checked | input[type="checkbox", type="radio"], and switch | Selects the element whose checked attribute is true (unavailable for animation attributes). | +In addition to a single pseudo-class, a combination of pseudo-classes is supported. For example, **:focus:checked** selects the element whose **focus** and **checked** attributes are both set to **true**. The following table lists the supported single pseudo-class in descending order of priority. -The following is an example for you to use the **:active** pseudo-class to control the style when a user presses the button. +| Pseudo-class | Available Components | Description | +| --------- | ---------------------------------------- | ---------------------------------------- | +| :disabled | Components that support the **disabled** attribute | Selects the element whose **disabled** attribute is changed to **true** (unavailable for animation attributes). | +| :active | Components that support the click event
| Selects the element activated by a user. For example, a pressed button or a selected **tab-bar** (unavailable for animation attributes).| +| :waiting | button | Selects the element whose **waiting** attribute is **true** (unavailable for animation attributes). | +| :checked | input[type="checkbox", type="radio"], switch| Selects the element whose **checked** attribute is **true** (unavailable for animation attributes). | +The following is an example for you to use the **:active** pseudo-class to control the style when a user presses the button. ```html @@ -151,32 +143,30 @@ The following is an example for you to use the **:active** pseudo-class to contr ```css /* index.css */ .button:active { - background-color: #888888;/* After the button is activated, the background color is changed to #888888. */ + background-color: #888888;/* After the button is activated, the background color is changed to #888888. */ } ``` > **NOTE** > -> Pseudo-classes are not supported for the **\** component and its child components, including **\**, **\**, **\**, **\