Skip to content

Commit 10c61db

Browse files
committed
Refactor footer icons rendering to use a loop for social links.
1 parent 720e950 commit 10c61db

File tree

2 files changed

+23
-63
lines changed

2 files changed

+23
-63
lines changed

src/framework/resource/layout/component/footer-icons.php

Lines changed: 21 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,25 @@
55
use UIAwesome\Html\{Graphic\Svg};
66
use yii\helpers\Html;
77

8-
?>
8+
$socialLinks = [
9+
['icon' => 'github.svg', 'url' => 'https://github.com/yiisoft', 'title' => 'GitHub'],
10+
['icon' => 'slack.svg', 'url' => 'https://join.slack.com/t/yii/shared_invite/...', 'title' => 'Slack'],
11+
['icon' => 'facebook.svg', 'url' => 'https://www.facebook.com/groups/yiitalk/', 'title' => 'Facebook'],
12+
['icon' => 'twitter.svg', 'url' => 'https://twitter.com/yiiframework', 'title' => 'Twitter'],
13+
['icon' => 'telegram.svg', 'url' => 'https://t.me/yii_framework_in_english', 'title' => 'Telegram'],
14+
];
915

10-
<?= Html::a(
11-
Svg::widget()
12-
->attributes(['height' => '24', 'width' => '24'])
13-
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/github.svg'))
14-
->render(),
15-
'https://github.com/yiisoft',
16-
[
17-
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3',
18-
'rel' => 'noopener',
19-
'title' => 'GitHub',
20-
],
21-
) ?>
22-
<?= Html::a(
23-
Svg::widget()
24-
->attributes(['height' => '24', 'width' => '24'])
25-
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/slack.svg'))
26-
->render(),
27-
'https://join.slack.com/t/yii/shared_invite/enQtMzQ4MDExMDcyNTk2LTc0NDQ2ZTZhNjkzZDgwYjE4YjZlNGQxZjFmZDBjZTU3NjViMDE4ZTMxNDRkZjVlNmM1ZTA1ODVmZGUwY2U3NDA',
28-
[
29-
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3',
30-
'rel' => 'noopener',
31-
'title' => 'Slack',
32-
],
33-
) ?>
34-
<?= Html::a(
35-
Svg::widget()
36-
->attributes(['height' => '24', 'width' => '24'])
37-
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/facebook.svg'))
38-
->render(),
39-
'https://www.facebook.com/groups/yiitalk/',
40-
[
41-
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3',
42-
'rel' => 'noopener',
43-
'title' => 'Facebook',
44-
],
45-
) ?>
46-
<?= Html::a(
47-
Svg::widget()
48-
->attributes(['height' => '24', 'width' => '24'])
49-
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/twitter.svg'))
50-
->render(),
51-
'https://twitter.com/yiiframework',
52-
[
53-
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3',
54-
'rel' => 'noopener',
55-
'title' => 'Twitter',
56-
],
57-
) ?>
58-
<?= Html::a(
59-
Svg::widget()
60-
->attributes(['height' => '24', 'width' => '24'])
61-
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/telegram.svg'))
62-
->render(),
63-
'https://t.me/yii_framework_in_english',
64-
[
65-
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted hover:text-dark text-decoration-none ms-3',
66-
'rel' => 'noopener',
67-
'title' => 'Telegram',
68-
],
69-
) ?>
16+
foreach ($socialLinks as $link): ?>
17+
<?= Html::a(
18+
Svg::widget()
19+
->attributes(['height' => '24', 'width' => '24'])
20+
->filePath(Yii::getAlias('@npm/bootstrap-icons/icons/' . $link['icon']))
21+
->render(),
22+
$link['url'],
23+
[
24+
'class' => 'd-none d-sm-block d-md-block d-lg-block d-xl-block text-muted text-decoration-none ms-3',
25+
'rel' => 'noopener',
26+
'title' => $link['title'],
27+
],
28+
) ?>
29+
<?php endforeach;

src/framework/resource/layout/component/toggle_language.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use yii\{helpers\Url, web\View};
99

1010
/**
11-
* @var string $languageLabel
1211
* @var View $this
1312
*/
1413
LocaleAsset::register($this);
1514

15+
$languageLabel = 'site.selector.language.en';
1616
$items = [];
1717

1818
$locales = Yii::$app->params['app.localeurls.languages'] ?? [];
@@ -29,7 +29,7 @@
2929
}
3030

3131
$items[] = Html::a(
32-
'<i class="fi fi-' . $icon . ' fis me-2"></i> ' . Yii::t('app.basic', "site.selector.language.$key"),
32+
'<i class="fi fi-' . $icon . ' fis me-2"></i> ' . Yii::t('app.basic', $languageLabel),
3333
Url::current(['language' => $key]),
3434
[
3535
'class' => 'dropdown-item d-flex align-items-center' . (Yii::$app->language === $value ? ' active' : ''),

0 commit comments

Comments
 (0)