diff --git a/dist/docs/index.html b/dist/docs/index.html index 17ccabd..410f2b8 100644 --- a/dist/docs/index.html +++ b/dist/docs/index.html @@ -1,2 +1,2 @@ -Water.css

Water.css

Water.css is a just-add-css collection of styles to make simple websites like this just a little bit nicer.
Now you can write your simple static site with nice semantic html, and Water.css will manage the styling for you.

Get it already!
GitHub
Water.css - Make your tiny website just a little nicer | Product Hunt Embed

Installation

Paste this into the <head> of your HTML:

{{selectedVersion.fileSnippet}}

Version options:





Version info:

File {{ selectedVersion.fileName }}
Size (min+gzip) {{ selectedVersion.fileSize }}KB
Theme
Browser support
-

Goals

Is it responsive?

Heck yeah! It doesn't include any fancy styles so it's easily mobile responsive. Just add the famous responsive viewport tag and you'll be good to go!

In fact, try resizing this page. Everything flows super nicely as you'll see.

Element demos

This is supposed to be a demo page so we need more elements!

Form elements


Code

Below is some code, you can copy it with Ctrl-C. Did you know, alert(1) can show an alert in JavaScript!

// This logs a message to the console and check out the scrollbar.
console.log('Hello, world!')

Other

Here's a horizontal rule and image because I don't know where else to put them.

Example kitten

And here's a nicely marked up table!

Name Quantity Price
Godzilla 2 $299.99
Mozilla 10 $100,000.00
Quesadilla 1 $2.22

Typography

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque dictum hendrerit velit, quis ullamcorper sem congue ac. Quisque id magna rhoncus, sodales massa vel, vestibulum elit. Duis ornare accumsan egestas. Proin maximus lacus interdum leo molestie convallis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut iaculis risus eu felis feugiat, eu mollis neque elementum. Donec interdum, nisl id dignissim iaculis, felis dui aliquet dui, non fermentum velit lectus ac quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. This is strong, this is normal, this is just bold, and this is emphasized! And heck, here's a link.

"The HTML blockquote Element (or HTML Block Quotation Element) indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> cite element."
  1. Ordered list item 1
  2. Ordered list item 2
  3. Ordered list item 3

Addresses are also styled to be awesome!

john.doe@example.com
778-330-2389
666-666-6666

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6
\ No newline at end of file +Water.css

Water.css

Water.css is a drop-in collection of CSS styles to make simple websites like this just a little bit nicer.
Now you can write your simple static site with nice semantic html, and Water.css will manage the styling for you.

Get it already!
GitHub
Water.css - Make your tiny website just a little nicer | Product Hunt Embed

Installation

Paste this into the <head> of your HTML:

{{selectedVersion.fileSnippet}}

Version options:





Version info:

File {{ selectedVersion.fileName }}
Size (min+gzip) {{ selectedVersion.fileSize }}KB
Theme
Browser support
+

Goals

Is it responsive?

Heck yeah! It doesn't include any fancy styles so it's easily mobile responsive. Just add the famous responsive viewport tag and you'll be good to go!

In fact, try resizing this page. Everything flows super nicely as you'll see.

Element demos

This is supposed to be a demo page so we need more elements!

Form elements


Code

Below is some code, you can copy it with Ctrl-C. Did you know, alert(1) can show an alert in JavaScript!

// This logs a message to the console and check out the scrollbar.
console.log('Hello, world!')

Other

Here's a horizontal rule and image because I don't know where else to put them.

Example kitten

And here's a nicely marked up table!

Name Quantity Price
Godzilla 2 $299.99
Mozilla 10 $100,000.00
Quesadilla 1 $2.22

Typography

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque dictum hendrerit velit, quis ullamcorper sem congue ac. Quisque id magna rhoncus, sodales massa vel, vestibulum elit. Duis ornare accumsan egestas. Proin maximus lacus interdum leo molestie convallis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut iaculis risus eu felis feugiat, eu mollis neque elementum. Donec interdum, nisl id dignissim iaculis, felis dui aliquet dui, non fermentum velit lectus ac quam. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. This is strong, this is normal, this is just bold, and this is emphasized! And heck, here's a link.

"The HTML blockquote Element (or HTML Block Quotation Element) indicates that the enclosed text is an extended quotation. Usually, this is rendered visually by indentation (see Notes for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> cite element."
  1. Ordered list item 1
  2. Ordered list item 2
  3. Ordered list item 3

Addresses are also styled to be awesome!

john.doe@example.com
778-330-2389
666-666-6666

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6
\ No newline at end of file diff --git a/dist/docs/script.js b/dist/docs/script.js index e867b29..c9cbf15 100644 --- a/dist/docs/script.js +++ b/dist/docs/script.js @@ -1,2 +1,2 @@ -"use strict";var e=window,t="https://cdn.jsdelivr.net/gh/kognise/water.css/dist/",n={"dark.min.css":1.4,"dark.standalone.min.css":1.31,"dark-legacy.min.css":2.487,"dark-legacy.standalone.min.css":1.16,"light.min.css":1.4,"light.standalone.min.css":1.3,"light-legacy.min.css":.178+1.16+1.15,"light-legacy.standalone.min.css":1.15},s=function(e){var t=e.theme,n=e.isLegacy?"-legacy":"",s=e.isStandalone?".standalone":"";return"".concat(t).concat(n).concat(s,".min.css")},r=function(e){var n=e.theme,r=e.isLegacy,i=e.isStandalone,c=s({theme:n,isLegacy:r,isStandalone:i}),a='');return!r||i?a:(function(e){var n=e.theme,r=e.isLegacy,i=e.isStandalone,c="dark"===n?"light":"dark",a=s({theme:c,isLegacy:r,isStandalone:i});return'\n\x3c!-- Preload the required stylesheets (optional) --\x3e\n\n')}({theme:n,isLegacy:r,isStandalone:!0})+"\n\n"+a).trim()},i={_productHunt:document.querySelector("#js-producthunt"),_stylesheet:document.querySelector("#js-stylesheet"),_updateProductHunt:function(e){this._productHunt.src=this._productHunt.src.replace(/dark|light/,e)},_updateStylesheet:function(e){this._stylesheet.href="../"+e},update:function(e,t){var n=e.isStandalone?e.theme:t||e.theme;this._updateStylesheet(s(e)),this._updateProductHunt(n)}},c=function(t,n){var s=e.matchMedia("(prefers-color-scheme: ".concat(t,")"));s.addListener(function(e){return n(e.matches)}),n(s.matches)};new e.Vue({el:"#installation",filters:{capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}},data:{versionOptions:{theme:"dark",isStandalone:!1,isLegacy:!1},preferedColorScheme:null,copyStatus:null},computed:{selectedVersion:function(){return{fileName:s(this.versionOptions),fileSize:(e=this.versionOptions,n[s(e)]||0).toFixed(2),fileSnippet:r(this.versionOptions)};var e}},created:function(){var e=this;c("dark",function(t){return t&&(e.preferedColorScheme="dark")}),c("light",function(t){return t&&(e.preferedColorScheme="light")}),this.preferedColorScheme&&i._updateProductHunt(this.preferedColorScheme)},methods:{copyToClipboard:function(){var t=this;Promise.resolve().then(function(){return e.clipboard.writeText(t.selectedVersion.fileSnippet)}).then(function(){return t.copyStatus="success"}).catch(function(){return t.copyStatus="failed"}),setTimeout(function(){return t.copyStatus=null},1e3)}},watch:{preferedColorScheme:function(e){i.update(this.versionOptions,e)},versionOptions:{deep:!0,handler:function(e){i.update(e,this.preferedColorScheme)}}}}); +"use strict";var e=window,t=new URLSearchParams(e.location.search),n="https://cdn.jsdelivr.net/gh/kognise/water.css/dist/",s={"dark.min.css":1.4,"dark.standalone.min.css":1.31,"dark-legacy.min.css":2.487,"dark-legacy.standalone.min.css":1.16,"light.min.css":1.4,"light.standalone.min.css":1.3,"light-legacy.min.css":.178+1.16+1.15,"light-legacy.standalone.min.css":1.15},a=function(e){var t=e.theme,n=e.isLegacy?"-legacy":"",s=e.isStandalone?".standalone":"";return"".concat(t).concat(n).concat(s,".min.css")},i=function(e){var t=e.theme,s=e.isLegacy,i=e.isStandalone,r=a({theme:t,isLegacy:s,isStandalone:i}),c='');return!s||i?c:(function(e){var t=e.theme,s=e.isLegacy,i=e.isStandalone,r="dark"===t?"light":"dark",c=a({theme:r,isLegacy:s,isStandalone:i});return'\n\x3c!-- Preload the required stylesheets (optional) --\x3e\n\n')}({theme:t,isLegacy:s,isStandalone:!0})+"\n\n"+c).trim()},r={_productHunt:document.querySelector("#js-producthunt"),_stylesheet:document.querySelector("#js-stylesheet"),_updateProductHunt:function(e){this._productHunt.src=this._productHunt.src.replace(/dark|light/,e)},_updateStylesheet:function(e){this._stylesheet.href="../"+e},update:function(e,t){var n=e.isStandalone?e.theme:t||e.theme;this._updateStylesheet(a(e)),this._updateProductHunt(n)}},c=function(t,n){var s=e.matchMedia("(prefers-color-scheme: ".concat(t,")"));s.addListener(function(e){return n(e.matches)}),n(s.matches)},o=t.get("theme"),l={theme:/dark|light/.test(o)?o:"dark",isLegacy:t.has("legacy"),isStandalone:t.has("standalone")};new e.Vue({el:"#installation",filters:{capitalize:function(e){return e.charAt(0).toUpperCase()+e.slice(1)}},data:{versionOptions:l,preferedColorScheme:null,copyStatus:null},computed:{selectedVersion:function(){return{fileName:a(this.versionOptions),fileSize:(e=this.versionOptions,s[a(e)]||0).toFixed(2),fileSnippet:i(this.versionOptions)};var e}},created:function(){var e=this;c("dark",function(t){return t&&(e.preferedColorScheme="dark")}),c("light",function(t){return t&&(e.preferedColorScheme="light")}),r.update(this.versionOptions,this.preferedColorScheme)},methods:{copyToClipboard:function(){var t=this;Promise.resolve().then(function(){return e.clipboard.writeText(t.selectedVersion.fileSnippet)}).then(function(){return t.copyStatus="success"}).catch(function(){return t.copyStatus="failed"}),setTimeout(function(){return t.copyStatus=null},1e3)}},watch:{preferedColorScheme:function(e){r.update(this.versionOptions,e)},versionOptions:{deep:!0,handler:function(e){r.update(e,this.preferedColorScheme)}}}}); //# sourceMappingURL=script.js.map diff --git a/dist/docs/script.js.map b/dist/docs/script.js.map index 498d0b8..074cc33 100644 --- a/dist/docs/script.js.map +++ b/dist/docs/script.js.map @@ -1 +1 @@ -{"version":3,"sources":["script.js"],"names":["w","window","CDN_BASE","FILE_SIZES","dark.min.css","dark.standalone.min.css","dark-legacy.min.css","dark-legacy.standalone.min.css","light.min.css","light.standalone.min.css","light-legacy.min.css","light-legacy.standalone.min.css","getFileName","_ref","theme","legacySuffix","isLegacy","standaloneExt","isStandalone","concat","getFileSnippet","_ref3","fileName","stylesheetSnippet","_ref2","alternativeTheme","alternativeFile","getFilePreloadSnippet","trim","externalElements","_productHunt","document","querySelector","_stylesheet","_updateProductHunt","this","src","replace","_updateStylesheet","href","update","options","preferedTheme","displayedTheme","createColorSchemeListener","scheme","queryHandler","mediaQuery","matchMedia","addListener","query","matches","Vue","el","filters","capitalize","str","charAt","toUpperCase","slice","data","versionOptions","preferedColorScheme","copyStatus","computed","selectedVersion","fileSize","toFixed","fileSnippet","created","_this","match","methods","copyToClipboard","_this2","Promise","resolve","then","clipboard","writeText","setTimeout","watch","nextScheme","deep","handler","nextOptions"],"mappings":"AAAA,aAQA,IAAMA,EAAuCC,OAKvCC,EAAW,sDAGXC,EAAa,CACjBC,eAAgB,IAChBC,0BAA2B,KAC3BC,sBAAuB,MACvBC,iCAAkC,KAClCC,gBAAiB,IACjBC,2BAA4B,IAC5BC,uBAAwB,KAAQ,KAAO,KACvCC,kCAAmC,MAI/BC,EAAc,SAAAC,GAAqE,IAApCC,EAAoCD,EAApCC,MAC7CC,EADiFF,EAA7BG,SAC1B,UAAY,GACtCC,EAFiFJ,EAAnBK,aAE/B,cAAgB,GACrD,MAAA,GAAAC,OAAmCL,GAAnCK,OAA2CJ,GAA3CI,OAA0DF,EAA1D,aAmBIG,EAAiB,SAAAC,GAAqE,IAApCP,EAAoCO,EAApCP,MAAOE,EAA6BK,EAA7BL,SAAUE,EAAmBG,EAAnBH,aACjEI,EAAWV,EAAY,CAAEE,MAAAA,EAAOE,SAAAA,EAAUE,aAAAA,IAC1CK,EAAiB,gCAAAJ,OAAmCjB,GAAnCiB,OAA8CG,EAA9C,MAEvB,OAAKN,GAAYE,EAAqBK,GAfV,SAAAC,GAAqE,IAApCV,EAAoCU,EAApCV,MAAOE,EAA6BQ,EAA7BR,SAAUE,EAAmBM,EAAnBN,aACxEO,EAA6B,SAAVX,EAAmB,QAAU,OAChDY,EAAkBd,EAAY,CAAEE,MAAOW,EAAkBT,SAAAA,EAAUE,aAAAA,IAEzE,MAAA,sGAAAC,OAEqCjB,GAFrCiB,OAEgDP,EAAY,CAAEE,MAAAA,EAAOE,SAAAA,EAAUE,aAAAA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GAAK,OAAIA,IAAUD,EAAKR,oBAAsB,UAChFlB,EAA0B,QAAS,SAAA2B,GAAK,OAAIA,IAAUD,EAAKR,oBAAsB,WAE7E3B,KAAK2B,qBAAqBjC,EAAiBK,mBAAmBC,KAAK2B,sBAEzEU,QAAS,CACPC,gBADO,WACW,IAAAC,EAAAvC,KAChBwC,QAAQC,UACLC,KAAK,WAAA,OAAM7E,EAAE8E,UAAUC,UAAUL,EAAKT,gBAAgBG,eACtDS,KAAK,WAAA,OAAOH,EAAKX,WAAa,YAFjC,MAGS,WAAA,OAAOW,EAAKX,WAAa,WAClCiB,WAAW,WAAA,OAAON,EAAKX,WAAa,MAAO,OAG/CkB,MAAO,CACLnB,oBADK,SACoCoB,GACvCrD,EAAiBW,OAAOL,KAAK0B,eAAgBqB,IAE/CrB,eAAgB,CACdsB,MAAM,EACNC,QAFc,SAEwBC,GACpCxD,EAAiBW,OAAO6C,EAAalD,KAAK2B","file":"script.js","sourcesContent":["// @ts-check\n/** @typedef {'dark' | 'light'} Theme */\n/** @typedef {keyof typeof FILE_SIZES} FileName */\n/** @typedef {'success' | 'failed'} CopyStatus */\n/** @typedef {{ Vue: typeof import('vue').default, clipboard: Clipboard }} Libraries */\n/** @typedef {{ theme: Theme, isLegacy: boolean, isStandalone: boolean }} VersionOptions */\n\n/** Reference to global window, but with properties for loaded libraries. */\nconst w = /** @type {Window & Libraries} */ (window)\n\n/** The base URI from where the docs page loads the CSS files. */\nconst DEV_BASE = '../'\n/** The base URI from where instructions show to load the CSS files. */\nconst CDN_BASE = 'https://cdn.jsdelivr.net/gh/kognise/water.css/dist/'\n\n/** An object mapping the (minified + gzipped) fileSize in KB to a fileName. */\nconst FILE_SIZES = {\n 'dark.min.css': 1.4,\n 'dark.standalone.min.css': 1.31,\n 'dark-legacy.min.css': 0.177 + 1.16 + 1.15,\n 'dark-legacy.standalone.min.css': 1.16,\n 'light.min.css': 1.4,\n 'light.standalone.min.css': 1.3,\n 'light-legacy.min.css': 0.178 + 1.16 + 1.15,\n 'light-legacy.standalone.min.css': 1.15,\n}\n\n/** Takes in version options and returns the respective CSS file name. */\nconst getFileName = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const legacySuffix = isLegacy ? '-legacy' : ''\n const standaloneExt = isStandalone ? '.standalone' : ''\n return /** @type {FileName} */ (`${theme}${legacySuffix}${standaloneExt}.min.css`)\n}\n\n/** Takes in version options and returns the corresponding file size in KB. */\nconst getFileSize = (/** @type {VersionOptions} */ options) => FILE_SIZES[getFileName(options)] || 0\n\n/** Takes in version options and returns an HTML snippet that preloads the main stylesheet and\n * conditionally preloads the alternative stylesheet (if the alternative theme is active). */\nconst getFilePreloadSnippet = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const alternativeTheme = theme === 'dark' ? 'light' : 'dark'\n const alternativeFile = getFileName({ theme: alternativeTheme, isLegacy, isStandalone })\n\n return `\n\n\n`\n}\n\n/** Takes in version options and returns the code snippet instructing users how to load the file. */\nconst getFileSnippet = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const fileName = getFileName({ theme, isLegacy, isStandalone })\n const stylesheetSnippet = ``\n\n if (!isLegacy || isStandalone) return stylesheetSnippet\n\n const preloadSnippet = getFilePreloadSnippet({ theme, isLegacy, isStandalone: true })\n return (preloadSnippet + '\\n\\n' + stylesheetSnippet).trim()\n}\n\n/** Handles elements external to the version picker that still need to be kept\n * up to date with the current version, e.g. switching images from dark to light. */\nconst externalElements = {\n _productHunt: /** @type {HTMLImageElement} */ (document.querySelector('#js-producthunt')),\n _stylesheet: /** @type {HTMLLinkElement} */ (document.querySelector('#js-stylesheet')),\n _updateProductHunt(/** @type {Theme} */ theme) {\n this._productHunt.src = this._productHunt.src.replace(/dark|light/, theme)\n },\n _updateStylesheet(/** @type {FileName} */ fileName) {\n this._stylesheet.href = DEV_BASE + fileName\n },\n\n /** Takes current version + the user's prefered scheme and updates all external elements. */\n update(/** @type {VersionOptions} */ options, /** @type {?Theme} */ preferedTheme) {\n const displayedTheme = options.isStandalone ? options.theme : preferedTheme || options.theme\n\n this._updateStylesheet(getFileName(options))\n this._updateProductHunt(displayedTheme)\n },\n}\n\n/**\n * Sets up a media query for the given color scheme and runs the callback on change.\n * @param {Theme} scheme\n * @param {(matches: boolean) => any} queryHandler\n */\nconst createColorSchemeListener = (scheme, queryHandler) => {\n const mediaQuery = w.matchMedia(`(prefers-color-scheme: ${scheme})`)\n mediaQuery.addListener(query => queryHandler(query.matches))\n queryHandler(mediaQuery.matches)\n}\n\n/** @typedef {Object} VueData\n * @prop {VersionOptions} versionOptions\n * @prop {?CopyStatus} copyStatus\n * @prop {?Theme} preferedColorScheme\n */\n\nnew w.Vue({\n el: '#installation',\n filters: {\n capitalize: (/** @type {string} */ str) => str.charAt(0).toUpperCase() + str.slice(1),\n },\n /** @type {VueData} */\n data: {\n versionOptions: { theme: /** @type {Theme} */ ('dark'), isStandalone: false, isLegacy: false },\n preferedColorScheme: null,\n copyStatus: null,\n },\n computed: {\n /** @returns {{ fileName: string, fileSize: string, fileSnippet: string }} */\n selectedVersion() {\n return {\n fileName: getFileName(this.versionOptions),\n fileSize: getFileSize(this.versionOptions).toFixed(2),\n fileSnippet: getFileSnippet(this.versionOptions),\n }\n },\n },\n created() {\n createColorSchemeListener('dark', match => match && (this.preferedColorScheme = 'dark'))\n createColorSchemeListener('light', match => match && (this.preferedColorScheme = 'light'))\n\n if (this.preferedColorScheme) externalElements._updateProductHunt(this.preferedColorScheme)\n },\n methods: {\n copyToClipboard() {\n Promise.resolve()\n .then(() => w.clipboard.writeText(this.selectedVersion.fileSnippet))\n .then(() => (this.copyStatus = 'success'))\n .catch(() => (this.copyStatus = 'failed'))\n setTimeout(() => (this.copyStatus = null), 1000)\n },\n },\n watch: {\n preferedColorScheme(/** @type {Theme} */ nextScheme) {\n externalElements.update(this.versionOptions, nextScheme)\n },\n versionOptions: {\n deep: true,\n handler(/** @type {VersionOptions} */ nextOptions) {\n externalElements.update(nextOptions, this.preferedColorScheme)\n },\n },\n },\n})\n"]} \ No newline at end of file +{"version":3,"sources":["script.js"],"names":["w","window","queryParams","URLSearchParams","location","search","CDN_BASE","FILE_SIZES","dark.min.css","dark.standalone.min.css","dark-legacy.min.css","dark-legacy.standalone.min.css","light.min.css","light.standalone.min.css","light-legacy.min.css","light-legacy.standalone.min.css","getFileName","_ref","theme","legacySuffix","isLegacy","standaloneExt","isStandalone","concat","getFileSnippet","_ref3","fileName","stylesheetSnippet","_ref2","alternativeTheme","alternativeFile","getFilePreloadSnippet","trim","externalElements","_productHunt","document","querySelector","_stylesheet","_updateProductHunt","this","src","replace","_updateStylesheet","href","update","options","preferedTheme","displayedTheme","createColorSchemeListener","scheme","queryHandler","mediaQuery","matchMedia","addListener","query","matches","themeFromParams","get","initialVersionOptions","test","has","Vue","el","filters","capitalize","str","charAt","toUpperCase","slice","data","versionOptions","preferedColorScheme","copyStatus","computed","selectedVersion","fileSize","toFixed","fileSnippet","created","_this","match","methods","copyToClipboard","_this2","Promise","resolve","then","clipboard","writeText","setTimeout","watch","nextScheme","deep","handler","nextOptions"],"mappings":"AAAA,aAcA,IAAMA,EAAuCC,OACvCC,EAAc,IAAIC,gBAAgBH,EAAEI,SAASC,QAK7CC,EAAW,sDAGXC,EAAa,CACjBC,eAAgB,IAChBC,0BAA2B,KAC3BC,sBAAuB,MACvBC,iCAAkC,KAClCC,gBAAiB,IACjBC,2BAA4B,IAC5BC,uBAAwB,KAAQ,KAAO,KACvCC,kCAAmC,MAI/BC,EAAc,SAAAC,GAAqE,IAApCC,EAAoCD,EAApCC,MAC7CC,EADiFF,EAA7BG,SAC1B,UAAY,GACtCC,EAFiFJ,EAAnBK,aAE/B,cAAgB,GACrD,MAAA,GAAAC,OAAmCL,GAAnCK,OAA2CJ,GAA3CI,OAA0DF,EAA1D,aAmBIG,EAAiB,SAAAC,GAAqE,IAApCP,EAAoCO,EAApCP,MAAOE,EAA6BK,EAA7BL,SAAUE,EAAmBG,EAAnBH,aACjE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,KAAKH,GAAmBA,EAAkB,OACpFpC,SAAUlB,EAAY0D,IAAI,UAC1BtC,aAAcpB,EAAY0D,IAAI,eAGhC,IAAI5D,EAAE6D,IAAI,CACRC,GAAI,gBACJC,QAAS,CACPC,WAAY,SAAuBC,GAAvB,OAA+BA,EAAIC,OAAO,GAAGC,cAAgBF,EAAIG,MAAM,KAGrFC,KAAM,CACJC,eAAgBZ,EAChBa,oBAAqB,KACrBC,WAAY,MAEdC,SAAU,CAERC,gBAFQ,WAGN,MAAO,CACLhD,SAAUV,EAAYuB,KAAK+B,gBAC3BK,UAhF2C9B,EAgFrBN,KAAK+B,eAhF4B/D,EAAWS,EAAY6B,KAAa,GAgFhD+B,QAAQ,GACnDC,YAAarD,EAAee,KAAK+B,iBAjFrB,IAA+BzB,IAqFjDiC,QArBQ,WAqBE,IAAAC,EAAAxC,KACRS,EAA0B,OAAQ,SAAAgC,GAAK,OAAIA,IAAUD,EAAKR,oBAAsB,UAChFvB,EAA0B,QAAS,SAAAgC,GAAK,OAAIA,IAAUD,EAAKR,oBAAsB,WAEjFtC,EAAiBW,OAAOL,KAAK+B,eAAgB/B,KAAKgC,sBAEpDU,QAAS,CACPC,gBADO,WACW,IAAAC,EAAA5C,KAChB6C,QAAQC,UACLC,KAAK,WAAA,OAAMtF,EAAEuF,UAAUC,UAAUL,EAAKT,gBAAgBG,eACtDS,KAAK,WAAA,OAAOH,EAAKX,WAAa,YAFjC,MAGS,WAAA,OAAOW,EAAKX,WAAa,WAClCiB,WAAW,WAAA,OAAON,EAAKX,WAAa,MAAO,OAG/CkB,MAAO,CACLnB,oBADK,SACoCoB,GACvC1D,EAAiBW,OAAOL,KAAK+B,eAAgBqB,IAE/CrB,eAAgB,CACdsB,MAAM,EACNC,QAFc,SAEwBC,GACpC7D,EAAiBW,OAAOkD,EAAavD,KAAKgC","file":"script.js","sourcesContent":["// @ts-check\n/** @typedef {'dark' | 'light'} Theme */\n/** @typedef {keyof typeof FILE_SIZES} FileName */\n/** @typedef {'success' | 'failed'} CopyStatus */\n/** @typedef {{ Vue: typeof import('vue').default, clipboard: Clipboard }} Libraries */\n/** @typedef {{ theme: Theme, isLegacy: boolean, isStandalone: boolean }} VersionOptions */\n\n/** @typedef {Object} VueData State used by the version picker\n * @prop {VersionOptions} versionOptions\n * @prop {?CopyStatus} copyStatus\n * @prop {?Theme} preferedColorScheme\n */\n\n/** Reference to global window, but with properties for loaded libraries. */\nconst w = /** @type {Window & Libraries} */ (window)\nconst queryParams = new URLSearchParams(w.location.search)\n\n/** The base URI from where the docs page loads the CSS files. */\nconst DEV_BASE = '../'\n/** The base URI from where instructions show to load the CSS files. */\nconst CDN_BASE = 'https://cdn.jsdelivr.net/gh/kognise/water.css/dist/'\n\n/** An object mapping the (minified + gzipped) fileSize in KB to a fileName. */\nconst FILE_SIZES = {\n 'dark.min.css': 1.4,\n 'dark.standalone.min.css': 1.31,\n 'dark-legacy.min.css': 0.177 + 1.16 + 1.15,\n 'dark-legacy.standalone.min.css': 1.16,\n 'light.min.css': 1.4,\n 'light.standalone.min.css': 1.3,\n 'light-legacy.min.css': 0.178 + 1.16 + 1.15,\n 'light-legacy.standalone.min.css': 1.15,\n}\n\n/** Takes in version options and returns the respective CSS file name. */\nconst getFileName = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const legacySuffix = isLegacy ? '-legacy' : ''\n const standaloneExt = isStandalone ? '.standalone' : ''\n return /** @type {FileName} */ (`${theme}${legacySuffix}${standaloneExt}.min.css`)\n}\n\n/** Takes in version options and returns the corresponding file size in KB. */\nconst getFileSize = (/** @type {VersionOptions} */ options) => FILE_SIZES[getFileName(options)] || 0\n\n/** Takes in version options and returns an HTML snippet that preloads the main stylesheet and\n * conditionally preloads the alternative stylesheet (if the alternative theme is active). */\nconst getFilePreloadSnippet = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const alternativeTheme = theme === 'dark' ? 'light' : 'dark'\n const alternativeFile = getFileName({ theme: alternativeTheme, isLegacy, isStandalone })\n\n return `\n\n\n`\n}\n\n/** Takes in version options and returns the code snippet instructing users how to load the file. */\nconst getFileSnippet = (/** @type {VersionOptions} */ { theme, isLegacy, isStandalone }) => {\n const fileName = getFileName({ theme, isLegacy, isStandalone })\n const stylesheetSnippet = ``\n\n if (!isLegacy || isStandalone) return stylesheetSnippet\n\n const preloadSnippet = getFilePreloadSnippet({ theme, isLegacy, isStandalone: true })\n return (preloadSnippet + '\\n\\n' + stylesheetSnippet).trim()\n}\n\n/** Handles elements external to the version picker that still need to be kept\n * up to date with the current version, e.g. switching images from dark to light. */\nconst externalElements = {\n _productHunt: /** @type {HTMLImageElement} */ (document.querySelector('#js-producthunt')),\n _stylesheet: /** @type {HTMLLinkElement} */ (document.querySelector('#js-stylesheet')),\n _updateProductHunt(/** @type {Theme} */ theme) {\n this._productHunt.src = this._productHunt.src.replace(/dark|light/, theme)\n },\n _updateStylesheet(/** @type {FileName} */ fileName) {\n this._stylesheet.href = DEV_BASE + fileName\n },\n\n /** Takes current version + the user's prefered scheme and updates all external elements. */\n update(/** @type {VersionOptions} */ options, /** @type {?Theme} */ preferedTheme) {\n const displayedTheme = options.isStandalone ? options.theme : preferedTheme || options.theme\n\n this._updateStylesheet(getFileName(options))\n this._updateProductHunt(displayedTheme)\n },\n}\n\n/**\n * Sets up a media query for the given color scheme and runs the callback on change.\n * @param {Theme} scheme\n * @param {(matches: boolean) => any} queryHandler\n */\nconst createColorSchemeListener = (scheme, queryHandler) => {\n const mediaQuery = w.matchMedia(`(prefers-color-scheme: ${scheme})`)\n mediaQuery.addListener(query => queryHandler(query.matches))\n queryHandler(mediaQuery.matches)\n}\n\nconst themeFromParams = queryParams.get('theme')\nconst initialVersionOptions = {\n theme: /** @type {Theme} */ (/dark|light/.test(themeFromParams) ? themeFromParams : 'dark'),\n isLegacy: queryParams.has('legacy'),\n isStandalone: queryParams.has('standalone'),\n}\n\nnew w.Vue({\n el: '#installation',\n filters: {\n capitalize: (/** @type {string} */ str) => str.charAt(0).toUpperCase() + str.slice(1),\n },\n /** @type {VueData} */\n data: {\n versionOptions: initialVersionOptions,\n preferedColorScheme: null,\n copyStatus: null,\n },\n computed: {\n /** @returns {{ fileName: string, fileSize: string, fileSnippet: string }} */\n selectedVersion() {\n return {\n fileName: getFileName(this.versionOptions),\n fileSize: getFileSize(this.versionOptions).toFixed(2),\n fileSnippet: getFileSnippet(this.versionOptions),\n }\n },\n },\n created() {\n createColorSchemeListener('dark', match => match && (this.preferedColorScheme = 'dark'))\n createColorSchemeListener('light', match => match && (this.preferedColorScheme = 'light'))\n\n externalElements.update(this.versionOptions, this.preferedColorScheme)\n },\n methods: {\n copyToClipboard() {\n Promise.resolve()\n .then(() => w.clipboard.writeText(this.selectedVersion.fileSnippet))\n .then(() => (this.copyStatus = 'success'))\n .catch(() => (this.copyStatus = 'failed'))\n setTimeout(() => (this.copyStatus = null), 1000)\n },\n },\n watch: {\n preferedColorScheme(/** @type {Theme} */ nextScheme) {\n externalElements.update(this.versionOptions, nextScheme)\n },\n versionOptions: {\n deep: true,\n handler(/** @type {VersionOptions} */ nextOptions) {\n externalElements.update(nextOptions, this.preferedColorScheme)\n },\n },\n },\n})\n"]} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index f9210de..f9f54e4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -55,7 +55,7 @@

Water.css

- Water.css is a just-add-css collection of styles to make simple websites like this just a + Water.css is a drop-in collection of CSS styles to make simple websites like this just a little bit nicer.
Now you can write your simple static site with nice semantic html, and Water.css will manage @@ -204,7 +204,7 @@ > for how to change it). A URL for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the - <cite> cite element." + <cite> cite element."