Skip to content

Commit

Permalink
chore:add mobile search icon
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfa committed Jan 2, 2025
1 parent 4c3a771 commit c0ce007
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 35 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ latest version : `0.1.0`
- update translation
- add post like button
- add copy post permalink
- add mobile search icon

### 0.0.16

Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- 修复错误
- 增加文章点赞
- 增加分享链接复制
- 增加移动端搜素按钮

### 0.0.16

Expand Down
2 changes: 1 addition & 1 deletion build/css/misc.css

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions build/js/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@ var heraBase = /** @class */ (function () {
};
return heraBase;
}());
if (document.querySelector('.nav--clicker')) {
var footerLogo = document.querySelector('.nav--clicker');
if (footerLogo) {
footerLogo.addEventListener('click', function () {
var body = document.querySelector('body');
if (body) {
body.classList.toggle('is-readingMode');
}
});
}
}
if (document.querySelector('.menu--icon')) {
document.querySelector('.menu--icon').addEventListener('click', function () {
document.querySelector('.site--nav').classList.add('is-active');
document.querySelector('body').classList.add('menu--actived');
});
}
if (document.querySelector('.search--icon')) {
document.querySelector('.search--icon').addEventListener('click', function () {
document.querySelector('body').classList.toggle('search--actived');
});
}
if (document.querySelector('.mask')) {
document.querySelector('.mask').addEventListener('touchstart', function () {
document.querySelector('.site--nav').classList.remove('is-active');
document.querySelector('body').classList.remove('menu--actived');
});
}
window.findParent = function (t, e, n) {
do {
if (e(t))
Expand Down
7 changes: 6 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
<body <?php body_class(''); ?>>
<main class="layout">
<div class="navbar">
<div class="js-contentFixed">
<div class="moblie--icon">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24" class="search--icon">
<path fill="currentColor" fill-rule="evenodd" d="M4.092 11.06a6.95 6.95 0 1 1 13.9 0 6.95 6.95 0 0 1-13.9 0m6.95-8.05a8.05 8.05 0 1 0 5.13 14.26l3.75 3.75a.56.56 0 1 0 .79-.79l-3.73-3.73A8.05 8.05 0 0 0 11.042 3z" clip-rule="evenodd"></path>
</svg>
<svg class="menu--icon" width="1em" height="1em" viewBox="0 0 24 14" fill="currentColor" aria-hidden="true">
<line x1="24" y1="1" y2="1" stroke="currentColor" stroke-width="2"></line>
<line x1="24" y1="7" x2="4" y2="7" stroke="currentColor" stroke-width="2"></line>
<line x1="24" y1="13" x2="8" y2="13" stroke="currentColor" stroke-width="2"></line>
</svg>
</div>
<div class="js-contentFixed">
<div class="site--info">
<a href="<?php echo home_url(); ?>" class="avatar--wrapper">
<img src="<?php echo ($heraSetting->get_setting('logo') ? $heraSetting->get_setting('logo') : get_template_directory_uri() . '/build/images/logo.png'); ?>" alt="<?php bloginfo('name'); ?>" class="avatar">
Expand Down
19 changes: 12 additions & 7 deletions scss/components/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,11 @@
}
}

.menu--icon {
.moblie--icon {
display: none;
width: 92%;
position: relative;
z-index: 1000;
}

.search--area {
Expand All @@ -301,6 +304,10 @@
margin-right: auto;
// max-width: 100%;
}
display: none;
.search--actived & {
display: flex;
}
}

.widget--links {
Expand Down Expand Up @@ -373,17 +380,15 @@
display: flex;
align-items: center;
flex-direction: column;
padding-top: 15px;
padding-top: 0px;
}

.site--description {
display: none;
}

.menu--icon {
position: fixed;
right: 20px;
top: 20px;
display: block;
.moblie--icon {
display: flex;
justify-content: space-between;
}
}
4 changes: 4 additions & 0 deletions scss/templates/_article.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
&--subline {
font-size: 16px;
}

&--header {
padding-top: 10px;
}
}
}

Expand Down
32 changes: 32 additions & 0 deletions ts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,35 @@ class heraBase {
}, 3000);
}
}

if (document.querySelector('.nav--clicker')) {
const footerLogo = document.querySelector('.nav--clicker');
if (footerLogo) {
footerLogo.addEventListener('click', function () {
const body = document.querySelector('body');
if (body) {
body.classList.toggle('is-readingMode');
}
});
}
}

if (document.querySelector('.menu--icon')) {
document.querySelector('.menu--icon')!.addEventListener('click', () => {
document.querySelector('.site--nav')!.classList.add('is-active');
document.querySelector('body')!.classList.add('menu--actived');
});
}

if (document.querySelector('.search--icon')) {
document.querySelector('.search--icon')!.addEventListener('click', () => {
document.querySelector('body')!.classList.toggle('search--actived');
});
}

if (document.querySelector('.mask')) {
document.querySelector('.mask')!.addEventListener('touchstart', () => {
document.querySelector('.site--nav')!.classList.remove('is-active');
document.querySelector('body')!.classList.remove('menu--actived');
});
}
26 changes: 0 additions & 26 deletions ts/modules/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@ class heraAction extends heraBase {
this.is_archive = obvInit.is_archive;
this.like_btn = document.querySelector(this.selctor);

if (document.querySelector('.nav--clicker')) {
const footerLogo = document.querySelector('.nav--clicker');
if (footerLogo) {
footerLogo.addEventListener('click', function () {
const body = document.querySelector('body');
if (body) {
body.classList.toggle('is-readingMode');
}
});
}
}

if (document.querySelector('.menu--icon')) {
document.querySelector('.menu--icon')!.addEventListener('click', () => {
document.querySelector('.site--nav')!.classList.add('is-active');
document.querySelector('body')!.classList.add('menu--actived');
});
}

if (document.querySelector('.mask')) {
document.querySelector('.mask')!.addEventListener('touchstart', () => {
document.querySelector('.site--nav')!.classList.remove('is-active');
document.querySelector('body')!.classList.remove('menu--actived');
});
}

if (this.like_btn) {
this.like_btn.addEventListener('click', () => {
this.handleLike();
Expand Down

0 comments on commit c0ce007

Please sign in to comment.