Protocol
ElevationCompositeSemanticTokens
This is a group of semantic tokens for elevations, but only composite tokens. There are splitted and not declared in ElevationSemanticTokens as the tokenator tool parsing Figma JSON to Swift code is not able to manage them. Thus we need to declare them in another file to prevent them to be erased. It declares in fact box shadows effects.
protocol ElevationCompositeSemanticTokens
Overview
This protocol makes themes able to provide and override ElevationCompositeSemanticToken. ElevationCompositeSemanticToken refers to MultipleElevationCompositeRawToken, which contains for light and dark color schemes ElevationCompositeRawToken. This ElevationCompositeRawToken is not managed by tokenator yet as it is composed by three properties.
This ElevationCompositeSemanticTokens protocol contains a set of ElevationCompositeSemanticToken. They can be applied to views and components using shadow(elevation:) or elevation(for:):
@Environment(\.theme) var theme
@Environment(\.colorScheme) var colorScheme
// Given you want to apply the elevation token "raised"
var body: some View {
// Apply the token of elevation for the shadow effect without managing yourself the color scheme
Rectangle()
.shadow(elevation: theme.elevations.raised))
}
// Or get the token depending to the color scheme and do whatever you want with
theme.elevations.raised.elevation(for: colorScheme)
Since
0.8.0
Topics
Instance Properties