Skip to content

Commit

Permalink
rename 'comic' into 'xkcd (related to multi-source suggestion #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
icmx committed May 5, 2021
1 parent e37e35a commit 10af092
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ xv is xkcd comics viwer app, done in pure JavaScript, CSS and Webpack.
- Classic navigation experience (Random comic included)
- Keyboard navigation: <kbd>←</kbd> / <kbd>→</kbd> for previous/next (<kbd>Shift</kbd> for first/last), <kbd>R</kbd> for random
- Routing: try [/#303](https://icmx-xv.netlify.app/#303) e.g.
- Transcript for ~1600 first comics, with [parsing](src/lib/comicparse)!
- Transcript for ~1600 first comics, with [parsing](src/lib/xkcdparse)!
- Mobile-first and desktop layouts
- Light and Dark modes without flashing on refresh — works with images too!

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import comics from './comics';
import xkcd from './xkcd';
import theme from './theme';

const Features = { comics, theme };
const Features = { xkcd, theme };

export default Features;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import $ from '~/lib/jeox';
import comicparse from '~/lib/comicparse';
import xkcdparse from '~/lib/xkcdparse';

import Core from '~/app/core';
import int from '~/app/utils/int';
Expand Down Expand Up @@ -212,10 +212,10 @@ class XkcdView extends Core.View {
break;
}

const title = comicparse.title(comic);
const alt = comicparse.alt(comic);
const date = comicparse.date(comic);
const transcript = comicparse.transcript(comic);
const title = xkcdparse.title(comic);
const alt = xkcdparse.alt(comic);
const date = xkcdparse.date(comic);
const transcript = xkcdparse.transcript(comic);

this.#title = `xv - #${comic.num}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import XkcdController from './XkcdController';

import XkcdApi from './XkcdApi';

const comics = new XkcdController({
const xkcd = new XkcdController({
model: new XkcdModel(new XkcdApi('/api/comics')),
view: new XkcdView(window.document.querySelector('.xv-app')),
});

export default comics;
export default xkcd;
2 changes: 1 addition & 1 deletion src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Core from './core';
import Features from './features';

const App = new Core.Controller({
childControllers: [Features.comics, Features.theme],
childControllers: [Features.xkcd, Features.theme],
});

export default App;
5 changes: 0 additions & 5 deletions src/lib/comicparse/index.js

This file was deleted.

14 changes: 7 additions & 7 deletions src/lib/comicparse/README.md → src/lib/xkcdparse/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# comicparse
# xkcdparse

xv internal library to destruct an xkcd comic JSON data and transform into nice plain text or HTML strings.

## How it works

comicparse has "destructors" API which are actually functions that takes xkcd comic JSON data. The following example will explain it better.
xkcdparse has "destructors" API which are actually functions that takes xkcd comic JSON data. The following example will explain it better.

Suppose there's [xkcd #927](https://xkcd.com/927/) JSON:

```js
import comicparse from '~/somewhere/comicparse';
import xkcdparse from '~/somewhere/xkcdparse';

// (multiline for readability)
const comic = {
Expand All @@ -29,21 +29,21 @@ const comic = {
// ...rest props
}

const a = comicparse.title(comic); // -> title destructor:
const a = xkcdparse.title(comic); // -> title destructor:
//
// Standards

const b = comicparse.alt(comic); // -> alt destructor:
const b = xkcdparse.alt(comic); // -> alt destructor:
//
// (multiline for readability)
// “Fortunately, the charging one has been solved now that we've all
// standardized on mini-USB. Or is it micro-USB? Shit.“

const c = comicparse.date(comic); // -> date destructor:
const c = xkcdparse.date(comic); // -> date destructor:
//
// Saturday, August 20, 2011

const d = comicparse.transcript(comic); // -> transcript destructor:
const d = xkcdparse.transcript(comic); // -> transcript destructor:
//
// (multiline for readability)
// HOW STANDARDS PROLIFERATE
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/lib/xkcdparse/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Core from './core';

const xkcdparse = Core;

export default xkcdparse;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import re from './re';
* @param {string} value
* @param {string} character
* @param {number} count
* @returns boolean
* @returns {boolean}
*/
const isRepeated = (value, character, count = 1) => {
const pattern = re`^\\${character}{${count},}$`;
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/styles/layout/appbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@
flex-shrink: 0;
flex-basis: 20%;
}

@media (min-width: 768px) {
.appbar.is-bottom > .actions > button {
min-width: 4rem;
}
}

0 comments on commit 10af092

Please sign in to comment.