Skip to content

Commit

Permalink
[Tokens][M3][Chip] Integrate Chip component tokens to Chip styles in M3.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 485965681
  • Loading branch information
raajkumars committed Nov 7, 2022
1 parent 276c117 commit cb65cc6
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 9 deletions.
37 changes: 28 additions & 9 deletions lib/java/com/google/android/material/chip/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,12 @@
<style name="Widget.Material3.Chip.Input" parent="Base.Widget.Material3.Chip">
<item name="android:checkable">true</item>

<item name="chipMinHeight">32dp</item>
<item name="chipIconSize">24dp</item>
<item name="shapeAppearance">@macro/m3_comp_input_chip_container_shape</item>
<item name="android:textAppearance">@macro/m3_comp_input_chip_label_text_type</item>
<item name="chipMinHeight">@dimen/m3_comp_input_chip_container_height</item>
<item name="chipIconSize">@dimen/m3_comp_input_chip_with_avatar_avatar_size</item>
<item name="chipStrokeWidth">@dimen/m3_comp_input_chip_unselected_outline_width</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/m3_comp_input_chip_container_elevation</item>

<item name="chipStartPadding">4dp</item>
<item name="iconStartPadding">0dp</item>
Expand Down Expand Up @@ -213,7 +217,7 @@
<!-- Style for input chips with system icons. For input chips with avatar
style icons, use Widget.Material3.Chip.Input, instead. -->
<style name="Widget.Material3.Chip.Input.Icon" parent="Widget.Material3.Chip.Input">
<item name="chipIconSize">@dimen/m3_chip_icon_size</item>
<item name="chipIconSize">@dimen/m3_comp_input_chip_with_leading_icon_leading_icon_size</item>
<item name="iconStartPadding">4dp</item>
</style>

Expand Down Expand Up @@ -248,7 +252,12 @@
<item name="checkedIconVisible">false</item>
<item name="closeIconVisible">false</item>

<item name="chipMinHeight">32dp</item>
<item name="shapeAppearance">@macro/m3_comp_suggestion_chip_container_shape</item>
<item name="android:textAppearance">@macro/m3_comp_suggestion_chip_label_text_type</item>
<item name="chipMinHeight">@dimen/m3_comp_suggestion_chip_container_height</item>
<item name="chipIconSize">@dimen/m3_comp_suggestion_chip_with_leading_icon_leading_icon_size</item>
<item name="chipStrokeWidth">@dimen/m3_comp_suggestion_chip_flat_outline_width</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/m3_comp_suggestion_chip_flat_container_elevation</item>

<item name="chipStartPadding">8dp</item>
<item name="iconStartPadding">0dp</item>
Expand All @@ -266,7 +275,7 @@
that needs protection, such as an image. -->
<style name="Widget.Material3.Chip.Suggestion.Elevated">
<item name="android:elevation" tools:ignore="NewApi">
@dimen/m3_chip_elevated_elevation
@dimen/m3_comp_suggestion_chip_elevated_container_elevation
</item>
<item name="android:stateListAnimator" tools:ignore="NewApi">
@animator/m3_elevated_chip_state_list_anim
Expand Down Expand Up @@ -295,7 +304,12 @@

<item name="android:textColor">@color/m3_chip_assist_text_color</item>

<item name="chipMinHeight">32dp</item>
<item name="shapeAppearance">@macro/m3_comp_assist_chip_container_shape</item>
<item name="android:textAppearance">@macro/m3_comp_assist_chip_label_text_type</item>
<item name="chipMinHeight">@dimen/m3_comp_assist_chip_container_height</item>
<item name="chipIconSize">@dimen/m3_comp_assist_chip_with_icon_icon_size</item>
<item name="chipStrokeWidth">@dimen/m3_comp_assist_chip_flat_outline_width</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/m3_comp_assist_chip_flat_container_elevation</item>

<item name="chipStartPadding">8dp</item>
<item name="iconStartPadding">0dp</item>
Expand All @@ -313,7 +327,7 @@
protection, such as an image. -->
<style name="Widget.Material3.Chip.Assist.Elevated">
<item name="android:elevation" tools:ignore="NewApi">
@dimen/m3_chip_elevated_elevation
@dimen/m3_comp_assist_chip_elevated_container_elevation
</item>
<item name="android:stateListAnimator" tools:ignore="NewApi">
@animator/m3_elevated_chip_state_list_anim
Expand All @@ -329,7 +343,12 @@

<item name="checkedIcon">@drawable/ic_m3_chip_check</item>

<item name="chipMinHeight">32dp</item>
<item name="shapeAppearance">@macro/m3_comp_filter_chip_container_shape</item>
<item name="android:textAppearance">@macro/m3_comp_filter_chip_label_text_type</item>
<item name="chipMinHeight">@dimen/m3_comp_filter_chip_container_height</item>
<item name="chipIconSize">@dimen/m3_comp_filter_chip_with_icon_icon_size</item>
<item name="chipStrokeWidth">@dimen/m3_comp_filter_chip_flat_unselected_outline_width</item>
<item name="android:elevation" tools:ignore="NewApi">@dimen/m3_comp_filter_chip_flat_container_elevation</item>

<item name="chipStartPadding">8dp</item>
<item name="iconStartPadding">0dp</item>
Expand All @@ -347,7 +366,7 @@
protection, such as an image. -->
<style name="Widget.Material3.Chip.Filter.Elevated">
<item name="android:elevation" tools:ignore="NewApi">
@dimen/m3_chip_elevated_elevation</item>
@dimen/m3_comp_filter_chip_elevated_container_elevation</item>
<item name="android:stateListAnimator" tools:ignore="NewApi">
@animator/m3_elevated_chip_state_list_anim
</item>
Expand Down
71 changes: 71 additions & 0 deletions lib/java/com/google/android/material/chip/res/values/tokens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!-- AUTOGENERATED FILE. DO NOT MODIFY. -->
<!-- Version: v0.126 -->

<resources>
<!-- Generated from token set (md.comp.input-chip) in default context. -->
<!-- Enabled - Avatar -->
<dimen name="m3_comp_input_chip_with_avatar_avatar_size">24dp</dimen>
<!-- Enabled - Container -->
<macro name="m3_comp_input_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>
<dimen name="m3_comp_input_chip_container_height">32dp</dimen>
<dimen name="m3_comp_input_chip_container_elevation">@dimen/m3_sys_elevation_level0</dimen>
<dimen name="m3_comp_input_chip_unselected_outline_width">1dp</dimen>
<!-- Enabled - Label text -->
<macro name="m3_comp_input_chip_label_text_type">?attr/textAppearanceLabelLarge</macro>
<!-- Enabled - Leading icon -->
<dimen name="m3_comp_input_chip_with_leading_icon_leading_icon_size">18dp</dimen>

<!-- Generated from token set (md.comp.suggestion-chip) in default context. -->
<!-- Enabled - Container -->
<macro name="m3_comp_suggestion_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>
<dimen name="m3_comp_suggestion_chip_with_leading_icon_leading_icon_size">18dp</dimen>
<dimen name="m3_comp_suggestion_chip_container_height">32dp</dimen>
<dimen name="m3_comp_suggestion_chip_flat_container_elevation">@dimen/m3_sys_elevation_level0</dimen>
<dimen name="m3_comp_suggestion_chip_flat_outline_width">1dp</dimen>
<dimen name="m3_comp_suggestion_chip_elevated_container_elevation">@dimen/m3_sys_elevation_level1</dimen>
<!-- Ignore (md.comp.suggestion-chip.elevated.container.shadow-color) due to no theme attribute for (md.sys.color.shadow). -->
<!-- Enabled - Label text -->
<macro name="m3_comp_suggestion_chip_label_text_type">?attr/textAppearanceLabelLarge</macro>

<!-- Generated from token set (md.comp.assist-chip) in default context. -->
<!-- Enabled - Container -->
<macro name="m3_comp_assist_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>
<dimen name="m3_comp_assist_chip_container_height">32dp</dimen>
<dimen name="m3_comp_assist_chip_flat_container_elevation">@dimen/m3_sys_elevation_level0</dimen>
<dimen name="m3_comp_assist_chip_flat_outline_width">1dp</dimen>
<dimen name="m3_comp_assist_chip_elevated_container_elevation">@dimen/m3_sys_elevation_level1</dimen>
<!-- Ignore (md.comp.assist-chip.elevated.container.shadow-color) due to no theme attribute for (md.sys.color.shadow). -->
<!-- Enabled - Label text -->
<macro name="m3_comp_assist_chip_label_text_type">?attr/textAppearanceLabelLarge</macro>
<!-- Enabled - Icon -->
<dimen name="m3_comp_assist_chip_with_icon_icon_size">18dp</dimen>

<!-- Generated from token set (md.comp.filter-chip) in default context. -->
<!-- Enabled - Container -->
<macro name="m3_comp_filter_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>
<dimen name="m3_comp_filter_chip_container_height">32dp</dimen>
<!-- Ignore (md.comp.filter-chip.container.shadow-color) due to no theme attribute for (md.sys.color.shadow). -->
<dimen name="m3_comp_filter_chip_flat_container_elevation">@dimen/m3_sys_elevation_level0</dimen>
<dimen name="m3_comp_filter_chip_flat_unselected_outline_width">1dp</dimen>
<dimen name="m3_comp_filter_chip_elevated_container_elevation">@dimen/m3_sys_elevation_level1</dimen>
<!-- Enabled - Label text -->
<macro name="m3_comp_filter_chip_label_text_type">?attr/textAppearanceLabelLarge</macro>
<!-- Enabled - Icon -->
<dimen name="m3_comp_filter_chip_with_icon_icon_size">18dp</dimen>
</resources>

0 comments on commit cb65cc6

Please sign in to comment.