diff --git a/common/src/MobileTooltip.scss b/common/src/MobileTooltip.scss
new file mode 100644
index 0000000..11933cb
--- /dev/null
+++ b/common/src/MobileTooltip.scss
@@ -0,0 +1,20 @@
+@media (pointer: coarse), (hover: none) {
+ .MobileTooltip {
+ position: relative;
+ display: inline-flex;
+ justify-content: center;
+
+ &:focus::after {
+ content: attr(title);
+ position: absolute;
+ top: 90%;
+ left: 0;
+ color: #000;
+ background-color: #fff;
+ border: 1px solid;
+ width: fit-content;
+ padding: 3px;
+ z-index: 10;
+ }
+ }
+}
diff --git a/common/src/MobileTooltip.tsx b/common/src/MobileTooltip.tsx
new file mode 100644
index 0000000..2d1aacf
--- /dev/null
+++ b/common/src/MobileTooltip.tsx
@@ -0,0 +1,31 @@
+import * as React from 'react';
+import {useEffect} from 'react';
+
+const MobileTooltipContext = React.createContext(false);
+
+export function MobileTooltipProvider({children}: React.PropsWithChildren<{}>): JSX.Element {
+ const [mobile, setMobile] = React.useState(false);
+
+ useEffect(() => {
+ if (!window.matchMedia)
+ return;
+
+ const match = window.matchMedia('(pointer: coarse), (hover: none)');
+ const callback = () => setMobile(match.matches);
+
+ callback();
+ match.addEventListener('change', callback);
+ return () => match.removeEventListener('change', callback);
+ }, [setMobile]);
+
+ return
+ {children}
+ ;
+}
+
+export function useMobileTooltipProps(): { className: string, tabIndex?: number } {
+ return {
+ className: 'MobileTooltip',
+ ...React.useContext(MobileTooltipContext) ? {tabIndex: 0} : {},
+ };
+}
diff --git a/frcal/src/Calendar.scss b/frcal/src/Calendar.scss
index f398db0..bc0971b 100644
--- a/frcal/src/Calendar.scss
+++ b/frcal/src/Calendar.scss
@@ -147,26 +147,6 @@
background: $gray-300;
}
-@media (pointer: coarse), (hover: none) {
- .Day-rural {
- position: relative;
- display: inline-flex;
- justify-content: center;
- text-decoration: underline dashed;
- }
-
- .Day-rural:focus::after {
- content: attr(title);
- position: absolute;
- top: 90%;
- color: #000;
- background-color: #fff;
- border: 1px solid;
- width: fit-content;
- padding: 3px;
- }
-}
-
.Calendar-month-name.input-group {
justify-content: center;
font-size: 0.75em;
diff --git a/frcal/src/Calendar.tsx b/frcal/src/Calendar.tsx
index e22bf56..e0dd067 100644
--- a/frcal/src/Calendar.tsx
+++ b/frcal/src/Calendar.tsx
@@ -15,6 +15,7 @@ import {
} from '@common/french';
import {jdnDate} from '@common/gregorian';
import {jdnLongCount} from '@common/longCount';
+import {useMobileTooltipProps} from '@common/MobileTooltip';
type MonthProps = {
year: number;
@@ -39,10 +40,11 @@ function DayDetail({jdn}: { jdn: number }): JSX.Element {
function NormalDay({year, month, day, todayJDN}: DateProps & { todayJDN: number }): JSX.Element {
const jdn = frJDN(year, month, day);
const rural = dateRuralName(month, day)!;
+ const mobile = useMobileTooltipProps();
return
{day}
{decadeNames[(day - 1) % 10]}
-
{rural.name}
+
;
}
diff --git a/frcal/src/index.scss b/frcal/src/index.scss
index 66205d5..a0fb809 100644
--- a/frcal/src/index.scss
+++ b/frcal/src/index.scss
@@ -9,6 +9,7 @@
@import 'bootstrap/scss/forms';
@import 'bootstrap/scss/root';
@import './consts';
+@import '@common/MobileTooltip.scss';
body {
padding-top: $spacer * 4;
diff --git a/frcal/src/index.tsx b/frcal/src/index.tsx
index ea43d74..19cf95e 100644
--- a/frcal/src/index.tsx
+++ b/frcal/src/index.tsx
@@ -4,12 +4,15 @@ import 'bootstrap/js/dist/collapse';
import './index.scss';
import App from './App';
import reportWebVitals from './reportWebVitals';
+import {MobileTooltipProvider} from '@common/MobileTooltip';
ReactDOM.render(
-
-
- ,
- document.getElementById('root')
+
+
+
+
+ ,
+ document.getElementById('root'),
);
// If you want to start measuring performance in your app, pass a function
diff --git a/jcal/src/Calendar.scss b/jcal/src/Calendar.scss
index cfbca10..dfd84fb 100644
--- a/jcal/src/Calendar.scss
+++ b/jcal/src/Calendar.scss
@@ -167,24 +167,3 @@
.Calendar-today-button {
max-width: 5em;
}
-
-@media (pointer: coarse), (hover: none) {
- .DayDetail abbr {
- position: relative;
- display: inline-flex;
- justify-content: center;
-
- &:focus::after {
- content: attr(title);
- position: absolute;
- top: 90%;
- left: 0;
- color: #000;
- background-color: #fff;
- border: 1px solid;
- width: fit-content;
- padding: 3px;
- z-index: 10;
- }
- }
-}
diff --git a/jcal/src/Calendar.tsx b/jcal/src/Calendar.tsx
index 70b5f41..45865e1 100644
--- a/jcal/src/Calendar.tsx
+++ b/jcal/src/Calendar.tsx
@@ -4,6 +4,7 @@ import {formatJG, jdnGregorian, JulianDay, JulianMonth, monthName, weekdayNames}
import {jdnLongCount} from '@common/longCount';
import {jdnJulian, julianJDN, julianMonthDays} from '@common/julian';
import {frDateFormat, frEndJD, frStartJD, jdnFrench} from '@common/french';
+import {useMobileTooltipProps} from '@common/MobileTooltip';
type MonthProps = {
year: number;
@@ -20,18 +21,19 @@ function WeekdayName({name}: { name: string }): JSX.Element {
function DayDetail({jdn}: { jdn: number }): JSX.Element {
const lc = jdnLongCount(jdn);
+ const mobile = useMobileTooltipProps();
return
-
+
-
G.{' '}
+
G.{' '}
{formatJG(jdnGregorian(jdn))}
{lc &&
-
LC{' '}
+
LC{' '}
{lc.join('.\u200b')}
}
{jdn >= frStartJD && jdn <= frEndJD &&
-
FR{' '}
+
FR{' '}
{frDateFormat(jdnFrench(jdn))}
}
;
diff --git a/jcal/src/index.scss b/jcal/src/index.scss
index 66205d5..a0fb809 100644
--- a/jcal/src/index.scss
+++ b/jcal/src/index.scss
@@ -9,6 +9,7 @@
@import 'bootstrap/scss/forms';
@import 'bootstrap/scss/root';
@import './consts';
+@import '@common/MobileTooltip.scss';
body {
padding-top: $spacer * 4;
diff --git a/jcal/src/index.tsx b/jcal/src/index.tsx
index ea43d74..19cf95e 100644
--- a/jcal/src/index.tsx
+++ b/jcal/src/index.tsx
@@ -4,12 +4,15 @@ import 'bootstrap/js/dist/collapse';
import './index.scss';
import App from './App';
import reportWebVitals from './reportWebVitals';
+import {MobileTooltipProvider} from '@common/MobileTooltip';
ReactDOM.render(
-
-
- ,
- document.getElementById('root')
+
+
+
+
+ ,
+ document.getElementById('root'),
);
// If you want to start measuring performance in your app, pass a function