From 30130e5e99bd6c944e34e40344a64a5901073491 Mon Sep 17 00:00:00 2001 From: MAYUR <74107137+mayur1377@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:50:11 +0000 Subject: [PATCH] feature : Option to show / hide author details (#899) * feature : option to show author details * added languages * feat: added dates proper format final --- src/features/quote/Quote.jsx | 20 ++++++++- src/features/quote/options/QuoteOptions.jsx | 7 ++++ src/features/time/Date.jsx | 46 +++++++++------------ src/i18n/locales/az.json | 1 + src/i18n/locales/azb.json | 1 + src/i18n/locales/bn.json | 1 + src/i18n/locales/de_DE.json | 1 + src/i18n/locales/en_GB.json | 1 + src/i18n/locales/en_US.json | 1 + src/i18n/locales/es.json | 1 + src/i18n/locales/es_419.json | 1 + src/i18n/locales/et.json | 1 + src/i18n/locales/fa.json | 1 + src/i18n/locales/fr.json | 1 + src/i18n/locales/id_ID.json | 1 + src/i18n/locales/lt.json | 1 + src/i18n/locales/lv.json | 1 + src/i18n/locales/nl.json | 1 + src/i18n/locales/no.json | 1 + src/i18n/locales/pt.json | 1 + src/i18n/locales/pt_BR.json | 1 + src/i18n/locales/ru.json | 3 +- src/i18n/locales/sl.json | 1 + src/i18n/locales/tr_TR.json | 1 + src/i18n/locales/zh_CN.json | 1 + src/i18n/locales/zh_Hant.json | 1 + 26 files changed, 69 insertions(+), 29 deletions(-) diff --git a/src/features/quote/Quote.jsx b/src/features/quote/Quote.jsx index e998ea08..21d44851 100644 --- a/src/features/quote/Quote.jsx +++ b/src/features/quote/Quote.jsx @@ -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 && ( + <>

{this.state.copy} {this.state.share} {this.state.favourited}

+ + )} ) : ( + <> + { this.authorDetails && ( + <>
{localStorage.getItem('authorImg') !== 'false' ? ( @@ -499,6 +512,9 @@ class Quote extends PureComponent { ) : null}
+ + )} + )} ); diff --git a/src/features/quote/options/QuoteOptions.jsx b/src/features/quote/options/QuoteOptions.jsx index 02d2c1a6..4efa5c5d 100644 --- a/src/features/quote/options/QuoteOptions.jsx +++ b/src/features/quote/options/QuoteOptions.jsx @@ -144,15 +144,22 @@ class QuoteOptions extends PureComponent { subtitle={variables.getMessage(`${QUOTE_SECTION}.additional`)} /> + diff --git a/src/features/time/Date.jsx b/src/features/time/Date.jsx index 42514110..0cc764b1 100644 --- a/src/features/time/Date.jsx +++ b/src/features/time/Date.jsx @@ -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') { diff --git a/src/i18n/locales/az.json b/src/i18n/locales/az.json index 2c2e4d2e..19e01024 100644 --- a/src/i18n/locales/az.json +++ b/src/i18n/locales/az.json @@ -413,6 +413,7 @@ "author": "Müəllif", "author_img": "Müəllif şəkli göstər", "author_link": "Müəllif linki", + "author_details": "Müəllif məlumatlarını", "buttons": { "copy": "Kopyala", "favourite": "Sevimli", diff --git a/src/i18n/locales/azb.json b/src/i18n/locales/azb.json index 8f3e723e..983f6b19 100644 --- a/src/i18n/locales/azb.json +++ b/src/i18n/locales/azb.json @@ -413,6 +413,7 @@ "author": "Müəllif", "author_img": "Müəllif şəklini göstər", "author_link": "Müəllif linki", + "author_details": "Müəllif məlumatlarını", "buttons": { "copy": "Kopyala", "favourite": "Sevimli", diff --git a/src/i18n/locales/bn.json b/src/i18n/locales/bn.json index db0b6753..b63b6267 100644 --- a/src/i18n/locales/bn.json +++ b/src/i18n/locales/bn.json @@ -163,6 +163,7 @@ "title": "Quote", "additional": "উদ্ধৃতি উইজেটের শৈলী কাস্টমাইজ করার জন্য অন্যান্য সেটিংস", "author_link": "লেখকের লিঙ্ক", + "author_details": "লেখকের বিস্তারিত তথ্য", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/de_DE.json b/src/i18n/locales/de_DE.json index 3209a1e1..dfe40416 100644 --- a/src/i18n/locales/de_DE.json +++ b/src/i18n/locales/de_DE.json @@ -163,6 +163,7 @@ "title": "Zitat", "additional": "Zusätzliche Einstellungen zum Anpassen des Zitate-Widgets", "author_link": "Autor Link", + "author_details": "Autor Details", "custom": "Benutzerdefiniertes Zitat", "custom_subtitle": "Legen Sie Ihre eigenen Zitate fest", "no_quotes": "Keine Zitate", diff --git a/src/i18n/locales/en_GB.json b/src/i18n/locales/en_GB.json index d23c86c2..d1e9fcf5 100644 --- a/src/i18n/locales/en_GB.json +++ b/src/i18n/locales/en_GB.json @@ -163,6 +163,7 @@ "title": "Quote", "additional": "Other settings to customise the style of the quote widget", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/en_US.json b/src/i18n/locales/en_US.json index defc3d8c..08306939 100644 --- a/src/i18n/locales/en_US.json +++ b/src/i18n/locales/en_US.json @@ -163,6 +163,7 @@ "title": "Quote", "additional": "Other settings to customise the style of the quote widget", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/es.json b/src/i18n/locales/es.json index 00feeec3..1d238cf2 100644 --- a/src/i18n/locales/es.json +++ b/src/i18n/locales/es.json @@ -413,6 +413,7 @@ "author": "Autor", "author_img": "Mostrar la imagen del autor", "author_link": "Enlace del autor", + "author_details": "Detalles del autor", "buttons": { "copy": "Botón de copiar", "favourite": "Botón de favoritos", diff --git a/src/i18n/locales/es_419.json b/src/i18n/locales/es_419.json index ea7e04f5..8b36f04c 100644 --- a/src/i18n/locales/es_419.json +++ b/src/i18n/locales/es_419.json @@ -163,6 +163,7 @@ "title": "Citación", "additional": "Other settings to customise the style of the quote widget", "author_link": "Enlace del autor", + "author_details": "Detalles del autor", "custom": "Citación personalizada", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/et.json b/src/i18n/locales/et.json index 358fa309..d2ee2422 100644 --- a/src/i18n/locales/et.json +++ b/src/i18n/locales/et.json @@ -413,6 +413,7 @@ "author": "Autor", "author_img": "Näita autori pilti", "author_link": "Autori link", + "author_details": "Näita autori üksikasju", "buttons": { "copy": "Kopeeri", "favourite": "Lisa lemmikuks", diff --git a/src/i18n/locales/fa.json b/src/i18n/locales/fa.json index eb971d12..0bbdc7d8 100644 --- a/src/i18n/locales/fa.json +++ b/src/i18n/locales/fa.json @@ -163,6 +163,7 @@ "title": "Quote", "additional": "Other settings to customise the style of the quote widget", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json index e2adab59..de3972e4 100644 --- a/src/i18n/locales/fr.json +++ b/src/i18n/locales/fr.json @@ -413,6 +413,7 @@ "author": "Auteur", "author_img": "Afficher l'image de l'auteur", "author_link": "Lien de l'auteur", + "author_details": "Détails de l'auteur", "buttons": { "copy": "Copier", "favourite": "Favori", diff --git a/src/i18n/locales/id_ID.json b/src/i18n/locales/id_ID.json index 9e904530..6e67263a 100644 --- a/src/i18n/locales/id_ID.json +++ b/src/i18n/locales/id_ID.json @@ -163,6 +163,7 @@ "title": "Kutipan", "additional": "Pengaturan lain untuk menyesuaikan gaya widget kutipan", "author_link": "Pranala penulis", + "author_details": "Tampilkan detail penulis", "custom": "Kutipan kustom", "custom_subtitle": "Tetapkan kutipan khusus Anda sendiri", "no_quotes": "Tidak ada kutipan", diff --git a/src/i18n/locales/lt.json b/src/i18n/locales/lt.json index ff449fad..1ca01d84 100644 --- a/src/i18n/locales/lt.json +++ b/src/i18n/locales/lt.json @@ -413,6 +413,7 @@ "author": "Autorius", "author_img": "Rodyti autoriaus nuotrauką", "author_link": "Autoriaus nuoroda", + "author_details": "Rodyti autoriaus informaciją", "buttons": { "copy": "Kopijuoti", "favourite": "Mėgstama", diff --git a/src/i18n/locales/lv.json b/src/i18n/locales/lv.json index 64ef9ce6..981908c0 100644 --- a/src/i18n/locales/lv.json +++ b/src/i18n/locales/lv.json @@ -413,6 +413,7 @@ "author": "Autors", "author_img": "Rādīt autora attēlu", "author_link": "Autora saite", + "author_details": "Rādīt autora detaļas", "buttons": { "copy": "Kopēt", "favourite": "Pievienot izlasei", diff --git a/src/i18n/locales/nl.json b/src/i18n/locales/nl.json index 5153d680..78ae714d 100644 --- a/src/i18n/locales/nl.json +++ b/src/i18n/locales/nl.json @@ -163,6 +163,7 @@ "title": "Citaat", "additional": "Andere instellingen om de stijl van het citaten widget te veranderen", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Schrijf je eigen citaten", "no_quotes": "Geen citaten", diff --git a/src/i18n/locales/no.json b/src/i18n/locales/no.json index d8909798..124d9f42 100644 --- a/src/i18n/locales/no.json +++ b/src/i18n/locales/no.json @@ -163,6 +163,7 @@ "title": "Sitat", "additional": "Other settings to customise the style of the quote widget", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/pt.json b/src/i18n/locales/pt.json index 8f3c53bb..c22228ee 100644 --- a/src/i18n/locales/pt.json +++ b/src/i18n/locales/pt.json @@ -163,6 +163,7 @@ "title": "Citações", "additional": "Outras configurações para personalizar o estilo do widget de citações", "author_link": "Ligação do autor", + "author_details": "Detalhes do autor", "custom": "Citação personalizada", "custom_subtitle": "Define as suas próprias citações personalizadas", "no_quotes": "sem aspas", diff --git a/src/i18n/locales/pt_BR.json b/src/i18n/locales/pt_BR.json index 82665d9c..068b2dbc 100644 --- a/src/i18n/locales/pt_BR.json +++ b/src/i18n/locales/pt_BR.json @@ -163,6 +163,7 @@ "title": "Citações", "additional": "Outras configurações para personalizar o estilo do widget de citações", "author_link": "link do autor", + "author_details": "Detalhes do autor", "custom": "Citação personalizada", "custom_subtitle": "Defina suas próprias citações personalizadas", "no_quotes": "sem aspas", diff --git a/src/i18n/locales/ru.json b/src/i18n/locales/ru.json index a637df49..0e3a4851 100644 --- a/src/i18n/locales/ru.json +++ b/src/i18n/locales/ru.json @@ -162,7 +162,8 @@ "quote": { "title": "Цитата", "additional": "Другие настройки для настройки стиля виджета котировок", - "author_link": "Author link", + "author_link": "Ссылка на автора", + "author_details:": "Сведения об авторе", "custom": "Пользовательская цитата", "custom_subtitle": "Установите свои собственные пользовательские цитаты", "no_quotes": "Без кавычек", diff --git a/src/i18n/locales/sl.json b/src/i18n/locales/sl.json index 49ac7300..3eb123bf 100644 --- a/src/i18n/locales/sl.json +++ b/src/i18n/locales/sl.json @@ -413,6 +413,7 @@ "author": "Avtor", "author_img": "Prikaži sliko avtorja", "author_link": "Povezava avtorja", + "author_details": "Podrobnosti avtorja", "buttons": { "copy": "Kopiraj", "favourite": "Priljubljeno", diff --git a/src/i18n/locales/tr_TR.json b/src/i18n/locales/tr_TR.json index beb35fa0..43f96c40 100644 --- a/src/i18n/locales/tr_TR.json +++ b/src/i18n/locales/tr_TR.json @@ -163,6 +163,7 @@ "title": "Alıntı", "additional": "Alıntı aracının stilini özelleştirmek için diğer ayarlar", "author_link": "Yazara dair bilgilendirme bağlantısı göster.", + "author_details": "Yazar hakkında daha fazla bilgi göster.", "custom": "Özel Alıntı", "custom_subtitle": "Kendi özel alıntınızı belirleyin, ekleyin.", "no_quotes": "Alıntı yok", diff --git a/src/i18n/locales/zh_CN.json b/src/i18n/locales/zh_CN.json index d4852d0e..f21bf93b 100644 --- a/src/i18n/locales/zh_CN.json +++ b/src/i18n/locales/zh_CN.json @@ -163,6 +163,7 @@ "title": "名言警句", "additional": "Other settings to customise the style of the quote widget", "author_link": "出处链接", + "author_details": "作者详情", "custom": "自定义名言", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes", diff --git a/src/i18n/locales/zh_Hant.json b/src/i18n/locales/zh_Hant.json index d4e79318..ca86c5b9 100644 --- a/src/i18n/locales/zh_Hant.json +++ b/src/i18n/locales/zh_Hant.json @@ -163,6 +163,7 @@ "title": "Quote", "additional": "Other settings to customise the style of the quote widget", "author_link": "Author link", + "author_details": "Author details", "custom": "Custom quote", "custom_subtitle": "Set your own custom quotes", "no_quotes": "No quotes",