Fix mobile navbar and misc cleanups (#25134)

- Fix and improve mobile navbar layout
- Apply all cleanups suggested in
https://github.com/go-gitea/gitea/pull/25111
- Make media query breakpoints match Fomantic's exactly
- Clean up whitespace in class on navbar items

Mobile navbar before and after:
<img width="745" alt="Screenshot 2023-06-08 at 08 40 56"
src="ca84b239-b10f-41db-8c06-dcf2b6dd9d28">
<img width="739" alt="Screenshot 2023-06-08 at 08 41 23"
src="09133c54-eb7e-4110-858c-ead23c3b7521">

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
silverwind 2023-06-09 11:10:51 +02:00 committed by GitHub
parent 623b3b590e
commit 6a075589bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 223 additions and 265 deletions

View file

@ -12,7 +12,6 @@
</div>
<a class="gt-df gt-ac muted" :href="subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content="textNewRepo">
<svg-icon name="octicon-plus"/>
<span class="sr-only">{{ textNewRepo }}</span>
</a>
</h4>
<div class="ui attached segment repos-search">
@ -121,7 +120,6 @@
</div>
<a class="gt-df gt-ac muted" v-if="canCreateOrganization" :href="subUrl + '/org/create'" :data-tooltip-content="textNewOrg">
<svg-icon name="octicon-plus"/>
<span class="sr-only">{{ textNewOrg }}</span>
</a>
</h4>
<div v-if="organizations.length" class="ui attached table segment gt-rounded-bottom">

View file

@ -20,18 +20,14 @@ export function initGlobalFormDirtyLeaveConfirm() {
}
export function initHeadNavbarContentToggle() {
const content = $('#navbar');
const toggle = $('#navbar-expand-toggle');
let isExpanded = false;
toggle.on('click', () => {
isExpanded = !isExpanded;
if (isExpanded) {
content.addClass('shown');
toggle.addClass('active');
} else {
content.removeClass('shown');
toggle.removeClass('active');
}
const navbar = document.getElementById('navbar');
const btn = document.getElementById('navbar-expand-toggle');
if (!navbar || !btn) return;
btn.addEventListener('click', () => {
const isExpanded = btn.classList.contains('active');
navbar.classList.toggle('navbar-menu-open', !isExpanded);
btn.classList.toggle('active', !isExpanded);
});
}

View file

@ -108,10 +108,15 @@ function showLineButton() {
createTippy(btn, {
trigger: 'click',
hideOnClick: true,
content: menu,
placement: 'right-start',
role: 'menu',
interactive: 'true',
onShow: (tippy) => {
tippy.popper.addEventListener('click', () => {
tippy.hide();
}, {once: true});
}
});
}

View file

@ -469,7 +469,6 @@ export function initRepoPullRequestReview() {
content: $panel[0],
placement: 'bottom',
trigger: 'click',
role: 'menu',
maxWidth: 'none',
interactive: true,
hideOnClick: true,

View file

@ -27,7 +27,8 @@ export function createTippy(target, opts = {}) {
visibleInstances.add(instance);
},
arrow: `<svg width="16" height="7"><path d="m0 7 8-7 8 7Z" class="tippy-svg-arrow-outer"/><path d="m0 8 8-7 8 7Z" class="tippy-svg-arrow-inner"/></svg>`,
...(opts?.role && {theme: opts.role}),
role: 'menu', // HTML role attribute, only tooltips should use "tooltip"
theme: opts.role || 'menu', // CSS theme, we support either "tooltip" or "menu"
...opts,
});
@ -68,6 +69,7 @@ function attachTooltip(target, content = null) {
content,
delay: 100,
role: 'tooltip',
theme: 'tooltip',
hideOnClick,
placement: target.getAttribute('data-tooltip-placement') || 'top-start',
...(target.getAttribute('data-tooltip-interactive') === 'true' ? {interactive: true, aria: {content: 'describedby', expanded: false}} : {}),