class Dimension
Dimension design token value.
Attributes
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase implements \Drupal\Core\Theme\DesignToken\DesignTokenValueInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Theme\Plugin\DesignTokenValue\Dimension extends \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase
- class \Drupal\Core\Theme\DesignToken\DesignTokenValuePluginBase implements \Drupal\Core\Theme\DesignToken\DesignTokenValueInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Plugin\ConfigurablePluginBase
- class \Drupal\Core\Plugin\ConfigurablePluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\DependencyInjection\AutowiredInstanceTrait, \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Dimension
5 files declare their use of Dimension
- DesignTokenConfigEntityKernelTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - DesignTokenPluginManagerTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ DesignTokenPluginManagerTest.php - DesignTokenValuePluginManagerKernelTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenValuePluginManagerKernelTest.php - DimensionTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ DimensionTest.php - TypographyTest.php in core/
tests/ Drupal/ Tests/ Core/ Theme/ DesignToken/ Plugin/ TypographyTest.php
13 string references to 'Dimension'
- core.design_token_values.schema.yml in core/
config/ schema/ core.design_token_values.schema.yml - core/config/schema/core.design_token_values.schema.yml
- DesignTokenConfigEntityKernelTest::testConfigSchema in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests config schema.
- DesignTokenConfigEntityKernelTest::testPreSave in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests preSave.
- DesignTokenConfigEntityKernelTest::testPreSave in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests preSave.
- DesignTokenConfigEntityKernelTest::testToCss in core/
tests/ Drupal/ KernelTests/ Core/ Theme/ DesignToken/ DesignTokenConfigEntityKernelTest.php - Tests CSS export.
File
-
core/
lib/ Drupal/ Core/ Theme/ Plugin/ DesignTokenValue/ Dimension.php, line 16
Namespace
Drupal\Core\Theme\Plugin\DesignTokenValueView source
class Dimension extends DesignTokenValuePluginBase {
/**
* An integer or floating-point value representing the numeric value.
*/
protected int|float $value;
/**
* Unit of distance.
*/
protected DimensionUnitInterface $unit;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() : array {
return [
'value' => 0,
'unit' => DimensionUnit::Px,
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) : static {
parent::setConfiguration($configuration);
$this->value = $this->configuration['value'];
$this->unit = $this->configuration['unit'] instanceof DimensionUnitInterface ? $this->configuration['unit'] : DimensionUnit::from($this->configuration['unit']);
return $this;
}
/**
* {@inheritdoc}
*/
public function toDtcg() : mixed {
return [
'value' => $this->value,
'unit' => $this->unit->value,
];
}
/**
* {@inheritdoc}
*/
public function toCss() : string {
return $this->value . $this->unit->value;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.