You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/widgets/Icon.php
+41-10Lines changed: 41 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -15,19 +15,42 @@
15
15
/**
16
16
* Icon can be used to display a Materialize icon.
17
17
*
18
-
* Please note that the Materialize icons are shipped in a separate font file. This font file is automatically registered
19
-
* by the [[\macgyer\yii2materializecss\assets\MaterializeAsset|MaterializeAsset]].
18
+
* To be compatible with GDPR (EU) the MaterializeFontAsset is not loaded automatically via the [[\macgyer\yii2materializecss\assets\MaterializeAsset|MaterializeAsset]]. The font asset requests the Material Icon font from Google servers (as stated in the Materialize docs).
19
+
* If you are not affected by GDPR, simply load the [[\macgyer\yii2materializecss\assets\MaterializeFontAsset|MaterializeFontAsset]] in your layout or AppAsset.
20
20
*
21
-
* If you do not load the default [[\macgyer\yii2materializecss\assets\MaterializeAsset|MaterializeAsset]] make sure to at least load
22
-
* [[\macgyer\yii2materializecss\assets\MaterializeFontAsset|MaterializeFontAsset]] (or another source providing the font file) to correctly
23
-
* display the icons.
21
+
* Otherwise you need to self-host the Material Icon font (i. e. do not request them from Google). You could use `material-icons` (https://www.npmjs.com/package/material-icons) to load the font files, CSS and SCSS from NPM and include them in your build process.
24
22
*
25
23
* @author Christoph Erdmann <yii2-materializecss@pluspunkt-coding.de>
26
24
* @package widgets
27
25
* @see https://materializecss.com/icons.html
28
26
*/
29
27
class Icon extends BaseWidget
30
28
{
29
+
/**
30
+
* Sets the [[size]] of the icon to "tiny".
31
+
*/
32
+
publicconstSIZE_TINY = 'tiny';
33
+
/**
34
+
* Sets the [[size]] of the icon to "small". This is the default.
35
+
*/
36
+
publicconstSIZE_SMALL = 'small';
37
+
/**
38
+
* Sets the [[size]] of the icon to "medium".
39
+
*/
40
+
publicconstSIZE_MEDIUM = 'medium';
41
+
/**
42
+
* Sets the [[size]] of the icon to "large".
43
+
*/
44
+
publicconstSIZE_LARGE = 'large';
45
+
/**
46
+
* Sets the [[position]] of the icon to "left".
47
+
*/
48
+
publicconstPOSITION_LEFT = 'left';
49
+
/**
50
+
* Sets the [[position]] of the icon to "right".
51
+
*/
52
+
publicconstPOSITION_RIGHT = 'right';
53
+
31
54
/**
32
55
* @var string the name of the icon.
33
56
*
@@ -40,11 +63,16 @@ class Icon extends BaseWidget
40
63
*
41
64
* Currently "left" and "right" are natively supported by Materialize, but you can set this property to a custom string
42
65
* which will be added to the HTML class attribute and thus can be individually styled.
43
-
*
44
-
* The default icon position is "left".
45
66
*/
46
67
public$position;
47
68
69
+
/**
70
+
* @var string the size of the icon.
71
+
*
72
+
* The default icon size is "small".
73
+
*/
74
+
public$size = self::SIZE_SMALL;
75
+
48
76
/**
49
77
* @var array the HTML options for the icon tag.
50
78
*
@@ -69,12 +97,15 @@ public function init()
69
97
if (!$this->name) {
70
98
thrownewInvalidConfigException('The icon name must be specified.');
0 commit comments