mirror of
https://github.com/mue/mue.git
synced 2026-07-18 22:44:08 +02:00
feature : Option to show / hide author details (#899)
* feature : option to show author details * added languages * feat: added dates proper format final
This commit is contained in:
@@ -82,6 +82,8 @@ class Quote extends PureComponent {
|
||||
this.quote = createRef();
|
||||
this.quotediv = createRef();
|
||||
this.quoteauthor = createRef();
|
||||
this.authorDetails = localStorage.getItem('authorDetails') === 'true' ? true : false;
|
||||
console.log("authorDetails", this.authorDetails);
|
||||
}
|
||||
|
||||
useFavourite() {
|
||||
@@ -355,8 +357,12 @@ class Quote extends PureComponent {
|
||||
|
||||
setZoom() {
|
||||
const zoomQuote = Number((localStorage.getItem('zoomQuote') || 100) / 100);
|
||||
this.quote.current.style.fontSize = `${0.8 * zoomQuote}em`;
|
||||
this.quoteauthor.current.style.fontSize = `${0.9 * zoomQuote}em`;
|
||||
if (this.quote.current) {
|
||||
this.quote.current.style.fontSize = `${0.8 * zoomQuote}em`;
|
||||
}
|
||||
if (this.quoteauthor.current) {
|
||||
this.quoteauthor.current.style.fontSize = `${0.9 * zoomQuote}em`;
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -429,6 +435,8 @@ class Quote extends PureComponent {
|
||||
|
||||
{localStorage.getItem('widgetStyle') === 'legacy' ? (
|
||||
<>
|
||||
{ this.authorDetails && (
|
||||
<>
|
||||
<div>
|
||||
<h1 className="quoteauthor" ref={this.quoteauthor}>
|
||||
<a
|
||||
@@ -445,8 +453,13 @@ class Quote extends PureComponent {
|
||||
<div style={{ display: 'flex', justifyContent: 'center', gap: '20px' }}>
|
||||
{this.state.copy} {this.state.share} {this.state.favourited}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{ this.authorDetails && (
|
||||
<>
|
||||
<div className="author-holder">
|
||||
<div className="author">
|
||||
{localStorage.getItem('authorImg') !== 'false' ? (
|
||||
@@ -499,6 +512,9 @@ class Quote extends PureComponent {
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -144,15 +144,22 @@ class QuoteOptions extends PureComponent {
|
||||
subtitle={variables.getMessage(`${QUOTE_SECTION}.additional`)}
|
||||
/>
|
||||
<Action>
|
||||
<Checkbox
|
||||
name="authorDetails"
|
||||
text = {variables.getMessage(`${QUOTE_SECTION}.author_details`)}
|
||||
element=".other"
|
||||
/>
|
||||
<Checkbox
|
||||
name="authorLink"
|
||||
text={variables.getMessage(`${QUOTE_SECTION}.author_link`)}
|
||||
element=".other"
|
||||
disabled={localStorage.getItem('authorDetails')==='false'}
|
||||
/>
|
||||
<Checkbox
|
||||
name="authorImg"
|
||||
text={variables.getMessage(`${QUOTE_SECTION}.author_img`)}
|
||||
element=".other"
|
||||
disabled={localStorage.getItem('authorDetails')==='false'}
|
||||
/>
|
||||
</Action>
|
||||
</Row>
|
||||
|
||||
@@ -45,7 +45,7 @@ export default class DateWidget extends PureComponent {
|
||||
if (timezone && timezone !== 'auto') {
|
||||
date = convertTimezone(date, timezone);
|
||||
}
|
||||
|
||||
|
||||
if (localStorage.getItem('weeknumber') === 'true') {
|
||||
this.getWeekNumber(date);
|
||||
} else if (this.state.weekNumber !== null) {
|
||||
@@ -53,18 +53,18 @@ export default class DateWidget extends PureComponent {
|
||||
weekNumber: null,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (localStorage.getItem('dateType') === 'short') {
|
||||
const dateDay = date.getDate();
|
||||
const dateMonth = date.getMonth() + 1;
|
||||
const dateYear = date.getFullYear();
|
||||
|
||||
|
||||
const zero = localStorage.getItem('datezero') === 'true';
|
||||
|
||||
|
||||
let day = zero ? ('00' + dateDay).slice(-2) : dateDay;
|
||||
let month = zero ? ('00' + dateMonth).slice(-2) : dateMonth;
|
||||
let year = dateYear;
|
||||
|
||||
|
||||
switch (localStorage.getItem('dateFormat')) {
|
||||
case 'MDY':
|
||||
day = dateMonth;
|
||||
@@ -78,7 +78,7 @@ export default class DateWidget extends PureComponent {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
let format;
|
||||
switch (localStorage.getItem('shortFormat')) {
|
||||
case 'dots':
|
||||
@@ -96,47 +96,41 @@ export default class DateWidget extends PureComponent {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this.setState({
|
||||
date: format,
|
||||
});
|
||||
} else {
|
||||
// Long date
|
||||
const lang = variables.languagecode.split('_')[0];
|
||||
|
||||
const datenth =
|
||||
localStorage.getItem('datenth') === 'true' ? nth(date.getDate()) : date.getDate();
|
||||
|
||||
const dateDay =
|
||||
localStorage.getItem('dayofweek') === 'true'
|
||||
? date.toLocaleDateString(lang, { weekday: 'long' })
|
||||
: '';
|
||||
const datenth = localStorage.getItem('datenth') === 'true' ? nth(date.getDate()) : date.getDate();
|
||||
const dateDay = localStorage.getItem('dayofweek') === 'true'
|
||||
? date.toLocaleDateString(lang, { weekday: 'long' })
|
||||
: '';
|
||||
const dateMonth = date.toLocaleDateString(lang, { month: 'long' });
|
||||
const dateYear = date.getFullYear();
|
||||
|
||||
let day = dateDay + ' ' + datenth;
|
||||
let month = dateMonth;
|
||||
let year = dateYear;
|
||||
|
||||
let formattedDate;
|
||||
|
||||
switch (localStorage.getItem('longFormat')) {
|
||||
case 'MDY':
|
||||
day = dateMonth;
|
||||
month = dateDay + ' ' + datenth;
|
||||
formattedDate = `${dateMonth} ${datenth}, ${dateYear}${dateDay ? `, ${dateDay}` : ''}`;
|
||||
break;
|
||||
case 'YMD':
|
||||
day = dateYear;
|
||||
year = dateDay + ' ' + datenth;
|
||||
formattedDate = `${dateYear} ${dateMonth} ${datenth}${dateDay ? `, ${dateDay}` : ''}`;
|
||||
break;
|
||||
// DMY
|
||||
default:
|
||||
formattedDate = `${datenth} ${dateMonth} ${dateYear}${dateDay ? `, ${dateDay}` : ''}`;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this.setState({
|
||||
date: `${day} ${month} ${year}`,
|
||||
date: formattedDate,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
componentDidMount() {
|
||||
EventBus.on('refresh', (data) => {
|
||||
if (data === 'date' || data === 'timezone') {
|
||||
|
||||
Reference in New Issue
Block a user