mirror of
https://github.com/mastodon/mastodon
synced 2024-11-27 14:28:24 +09:00
Change server rules to be collapsible
This commit is contained in:
parent
27e79da6b9
commit
2de60556ec
@ -230,62 +230,6 @@ function loaded() {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Rails.delegate(
|
||||
document,
|
||||
'button.status__content__spoiler-link',
|
||||
'click',
|
||||
function () {
|
||||
if (!(this instanceof HTMLButtonElement)) return;
|
||||
|
||||
const statusEl = this.parentNode?.parentNode;
|
||||
|
||||
if (
|
||||
!(
|
||||
statusEl instanceof HTMLDivElement &&
|
||||
statusEl.classList.contains('.status__content')
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
if (statusEl.dataset.spoiler === 'expanded') {
|
||||
statusEl.dataset.spoiler = 'folded';
|
||||
this.textContent = new IntlMessageFormat(
|
||||
localeData['status.show_more'] ?? 'Show more',
|
||||
locale,
|
||||
).format() as string;
|
||||
} else {
|
||||
statusEl.dataset.spoiler = 'expanded';
|
||||
this.textContent = new IntlMessageFormat(
|
||||
localeData['status.show_less'] ?? 'Show less',
|
||||
locale,
|
||||
).format() as string;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
document
|
||||
.querySelectorAll<HTMLButtonElement>('button.status__content__spoiler-link')
|
||||
.forEach((spoilerLink) => {
|
||||
const statusEl = spoilerLink.parentNode?.parentNode;
|
||||
|
||||
if (
|
||||
!(
|
||||
statusEl instanceof HTMLDivElement &&
|
||||
statusEl.classList.contains('.status__content')
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
const message =
|
||||
statusEl.dataset.spoiler === 'expanded'
|
||||
? (localeData['status.show_less'] ?? 'Show less')
|
||||
: (localeData['status.show_more'] ?? 'Show more');
|
||||
spoilerLink.textContent = new IntlMessageFormat(
|
||||
message,
|
||||
locale,
|
||||
).format() as string;
|
||||
});
|
||||
}
|
||||
|
||||
Rails.delegate(
|
||||
@ -439,6 +383,24 @@ Rails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
||||
});
|
||||
});
|
||||
|
||||
Rails.delegate(document, '.rules-list button', 'click', ({ target }) => {
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const button = target.closest('button');
|
||||
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (button.ariaExpanded === 'true') {
|
||||
button.ariaExpanded = 'false';
|
||||
} else {
|
||||
button.ariaExpanded = 'true';
|
||||
}
|
||||
});
|
||||
|
||||
function main() {
|
||||
ready(loaded).catch((error: unknown) => {
|
||||
console.error(error);
|
||||
|
@ -108,17 +108,6 @@
|
||||
background: lighten($white, 4%);
|
||||
}
|
||||
|
||||
// Change the background colors of status__content__spoiler-link
|
||||
.reply-indicator__content .status__content__spoiler-link,
|
||||
.status__content .status__content__spoiler-link {
|
||||
background: $ui-base-color;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background: lighten($ui-base-color, 4%);
|
||||
}
|
||||
}
|
||||
|
||||
.account-gallery__item a {
|
||||
background-color: $ui-base-color;
|
||||
}
|
||||
|
@ -32,6 +32,27 @@ $fluid-breakpoint: $maximum-width + 20px;
|
||||
font-weight: 500;
|
||||
counter-increment: list-counter;
|
||||
|
||||
button {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
text-align: start;
|
||||
font: inherit;
|
||||
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&[aria-expanded='false'] .rules-list__hint {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: counter(list-counter);
|
||||
position: absolute;
|
||||
|
@ -1073,26 +1073,6 @@ body > [data-popper-placement] {
|
||||
color: $highlight-text-color;
|
||||
}
|
||||
|
||||
.status__content__spoiler-link {
|
||||
background: $action-button-color;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background: lighten($action-button-color, 7%);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
&::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
&::-moz-focus-inner,
|
||||
&:focus,
|
||||
&:active {
|
||||
outline: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.status__content__text {
|
||||
display: none;
|
||||
|
||||
@ -1350,21 +1330,6 @@ body > [data-popper-placement] {
|
||||
color: $dark-text-color;
|
||||
}
|
||||
|
||||
.status__content__spoiler-link {
|
||||
display: inline-block;
|
||||
border-radius: 2px;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
color: $inverted-text-color;
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
padding: 0 6px;
|
||||
text-transform: uppercase;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.status__wrapper--filtered {
|
||||
color: $dark-text-color;
|
||||
border: 0;
|
||||
@ -1732,11 +1697,6 @@ body > [data-popper-placement] {
|
||||
height: 24px;
|
||||
margin: -1px 0 0;
|
||||
}
|
||||
|
||||
.status__content__spoiler-link {
|
||||
line-height: 24px;
|
||||
margin: -1px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.media-gallery,
|
||||
@ -2284,17 +2244,6 @@ a.account__display-name {
|
||||
.status__avatar {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
a.status__content__spoiler-link {
|
||||
background: $ui-base-lighter-color;
|
||||
color: $inverted-text-color;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background: lighten($ui-base-lighter-color, 7%);
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.notification__report {
|
||||
@ -6577,15 +6526,6 @@ a.status-card {
|
||||
color: $primary-text-color;
|
||||
}
|
||||
|
||||
.status__content__spoiler-link {
|
||||
color: $primary-text-color;
|
||||
background: $ui-primary-color;
|
||||
|
||||
&:hover {
|
||||
background: lighten($ui-primary-color, 8%);
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-option {
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
@ -19,6 +19,7 @@
|
||||
%ol.rules-list
|
||||
- @rules.each do |rule|
|
||||
%li
|
||||
%button{ type: 'button', aria: { expanded: 'false' } }
|
||||
.rules-list__text= rule.text
|
||||
.rules-list__hint= rule.hint
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user