Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nav date helper for navigating by date #16

Merged
merged 3 commits into from
May 9, 2024
Merged

Conversation

stephenwf
Copy link
Member

@stephenwf stephenwf commented Apr 23, 2024

This will produce an object that can be used to create a tree for navigating by decade, year, month or day. It will also optionally choose the best one (based on the first divergence).

Parsing the Cookbook example it can produce the following navigations:

Automatic choice:

1986
  January
    Wed Jan 01 1986
      1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
1987
  January
    Thu Jan 01 1987
      1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide"

By century:

1900 - 1999
  1980 - 1989
    1986
      January
        Wed Jan 01 1986
          1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide (1986-01-01T00:00:00+00:00)
    1987
      January
        Thu Jan 01 1987
          1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide (1987-01-01T00:00:00+00:00)"

By decade:

1980 - 1989
  1986
    January
      Wed Jan 01 1986
        1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
  1987
    January
      Thu Jan 01 1987
        1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By year:

1986
  January
    Wed Jan 01 1986
      1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
1987
  January
    Thu Jan 01 1987
      1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By month: (note, this adds year to the labels)

January 1986
  Wed Jan 01 1986
    1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
January 1987
  Thu Jan 01 1987
    1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

By day:

Wed Jan 01 1986
  1986 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide
Thu Jan 01 1987
  1987 Chesapeake and Ohio Canal, Washington, D.C., Maryland, West Virginia, official map and guide

The tree structure includes some basic information for rendering:

type T = {
  id: string;
  type: 'day';
  count: number;
  label: InternationalString;
}

And then also numeric representations if you want to build your own labels (e.g. year, day, month numbers)

The final resource includes:

interface DateNavigationResource {
  id: string;
  type: 'Manifest' | 'Canvas';
  label: InternationalString;
  navDate: string;
}

Copy link

codesandbox-ci bot commented Apr 23, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@stephenwf stephenwf merged commit d1b65bb into main May 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant