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

Preparing a sofatime standalone JavaScript library #1

Open
wants to merge 19 commits into
base: localizedFormat
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
*.swp
.idea
site/*

# Yarn-specific entries (where we're not using Zero-Install;
# see <https://yarnpkg.com/features/zero-installs> for more information):
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

783 changes: 783 additions & 0 deletions .yarn/releases/yarn-3.2.2.cjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-3.2.2.cjs
1 change: 0 additions & 1 deletion dayjs-1.9.5/dayjs.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dayjs-1.9.5/plugin/localizedFormat.js

This file was deleted.

1 change: 0 additions & 1 deletion dayjs-1.9.5/plugin/timezone.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dayjs-1.9.5/plugin/utc.min.js

This file was deleted.

113 changes: 98 additions & 15 deletions demo.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,106 @@
<!DOCTYPE html>
<!-- saved from url=(0044)https://sofadevsite.kinsta.cloud/?page_id=12 -->
<html lang="en-US">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>SoFA Timezone Selector Demo &amp; notes</title>

<link rel="stylesheet" id="sofatime-css-css" href="sofatime.css" media="all">

<script type="text/javascript" src="dayjs-1.9.5/dayjs.min.js" id="dayjs-js"></script>
<script type="text/javascript" src="dayjs-1.9.5/plugin/utc.min.js" id="dayjs-utc-js"></script>
<script type="text/javascript" src="dayjs-1.9.5/plugin/timezone.min.js" id="dayjs-tz-js"></script>
<script type="text/javascript" src="dayjs-1.9.5/plugin/localizedFormat.js" id="dayjs-localizedFormat-js"></script>
<script type="text/javascript" src="sofatime.js" id="sofatime-js"></script>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SoFA Timezone Selector Demo &amp; notes</title>

<style type="text/css">
div.testcase {
padding: 0.5em;
border: 1px solid grey;
margin-bottom: 0.5em;
}

div.testcase > div[data-sofatime] {
/*margin-right: 40px;*/
}
</style>
</head>

<body>
<div class="testcase">
<span data-sofatime="2021-01-01 05:00 UTC"></span>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-prominent-controls="true"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-ask-twenty-four="no"
data-prominent-controls="yes"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00 - 2021-01-01T02:00:00-05:00"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-02 05:00 UTC - 2021-01-02 07:00 UTC"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00 - 2021-01-01T02:00:00-05:00 - whatever"></div>
</div>
<div class="testcase">
<div data-sofatime="whatever"></div>
</div>
<div class="testcase">
<div data-sofatime="whatever - whatever"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-ask-twenty-four="false"></div>
</div>
<div class="testcase">
<pre>&lt;div data-sofatime="2021-01-01 05:00 UTC"
data-display-24h-toggle="false"&gt;&lt;/div&gt;</pre>
<div data-sofatime="2021-01-01 05:00 UTC"
data-display-24h-toggle="false"></div>
</div>
<div class="testcase">
<pre>&lt;div data-sofatime="2021-01-01 05:00 UTC"
data-display-24h-toggle="no"&gt;&lt;/div&gt;</pre>
<div data-sofatime="2021-01-01 05:00 UTC"
data-display-24h-toggle="no"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-allow-time-zone-select="false"></div>
</div>
<div class="testcase">
<pre>&lt;div data-sofatime="2021-01-01 05:00 UTC"
data-display-select="false"&gt;&lt;/div&gt;</pre>
<div data-sofatime="2021-01-01 05:00 UTC"
data-display-select="false"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-ask-twenty-four="false"
data-allow-time-zone-select="false"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-format="H:mm"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01 05:00 UTC"
data-format="LLLL"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00 - 2021-01-01T02:00:00-05:00"
data-display-times-only="both"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00 - 2021-01-01T02:00:00-05:00"
data-display-times-only="start"></div>
</div>
<div class="testcase">
<div data-sofatime="2021-01-01T00:00:00-05:00 - 2021-01-01T02:00:00-05:00"
data-display-times-only="end"></div>
</div>

<main class="wp-container-623d25390f4cd wp-block-group" id="wp--skip-link--target">
<div class="wp-container-623d25390dd9f wp-block-group"><h1 style="margin-bottom: var(--wp--custom--spacing--medium, 6rem);" class="alignwide wp-block-post-title">SoFA Timezone Selector Demo &amp; notes</h1>


Expand All @@ -36,7 +119,8 @@

<p>Find out what time this event is in your timezone by selecting your timezone from the dropdown below.</p>

<p>Event time:<br></p><div class="sofatime">
<p>Event time:<br></p><div class="sofatime"
data-format="LLLL">
<span class="raw-user-input">2021-01-01 05:00 UTC</span>
<div class="sofatime-24h-wrapper">
<input type="checkbox" class="sofatime-24h-checkbox" id="sofatime-24h-1">
Expand Down Expand Up @@ -1427,6 +1511,5 @@ <h2>Example with Start and End Time</h2>

<div class="wp-container-623d25390f1d4 wp-block-group">
</div>
</main>

</body></html>
15 changes: 15 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sofatime from './sofatime';

import jsontemplate from './template';
import './demo.css';
import './sofatime.css';
import tztemplate from './template.json';
import tzdata from './locale/en.json';

window.addEventListener('load', function () {
console.log('sofatime.js loaded!');
sofatime();
//const tzselectfragment = jsontemplate(document, tztemplate.rootpattern,
// tzdata);
//document.getElementById('template-test').appendChild(tzselectfragment);
})
Loading