Skip to content

Commit eef07b0

Browse files
authored
Merge pull request #9 from Carifio24/docs
Add documentation to composables and utility functions
2 parents ff8cfdb + fea502b commit eef07b0

17 files changed

+434
-23
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Deploy Docs
2+
3+
on:
4+
push:
5+
branches:
6+
main
7+
8+
permissions: read-all
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: '20.x'
24+
25+
- name: Set up yarn
26+
run: corepack enable && yarn set version 3.3.0
27+
28+
- name: Install
29+
run: yarn install
30+
31+
- name: Lint
32+
run: yarn lint
33+
34+
- name: Build
35+
run: yarn build
36+
37+
- name: Build docs
38+
run: yarn docs
39+
40+
- name: Deploy docs to GitHub Pages
41+
uses: JamesIves/github-pages-deploy-action@v4
42+
if: ${{ steps.draft.outputs.value }} == 'true'
43+
with:
44+
branch: gh-pages
45+
folder: docs
46+

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ jobs:
3333

3434
- name: Build
3535
run: yarn build
36+
37+
- name: Build docs
38+
run: yarn docs
39+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ tsconfig.tsbuildinfo
2424
**/tests_output/**
2525

2626
*.env
27+
28+
docs/

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"eslint-plugin-vue": "^9.8.0",
3030
"less": "^4.2.0",
3131
"less-loader": "^12.1.0",
32+
"typedoc": "^0.25.13",
33+
"typedoc-plugin-vue": "^1.1.0",
3234
"typescript": "^4.9.4",
3335
"vue-template-compiler": "^2.7.14",
3436
"webpack": "^5.75.0"
@@ -46,6 +48,7 @@
4648
"scripts": {
4749
"build": "vue-cli-service build --target lib --name index src/index.ts",
4850
"clean": "rimraf dist",
51+
"docs": "typedoc",
4952
"lint": "vue-cli-service lint src --no-fix"
5053
},
5154
"types": "./dist/src/index.d.ts"

src/background.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** Class representing a background imageset for WorldWide Telescope */
12
export class BackgroundImageset {
3+
/** The outward-facing name to use for the imageset in a story */
24
public imagesetName: string;
5+
/** The name of the imageset object inside WorldWide Telescope */
36
public displayName: string;
47

58
constructor(displayName: string, imagesetName: string) {
@@ -8,6 +11,7 @@ export class BackgroundImageset {
811
}
912
}
1013

14+
/** A default list of `BackgroundImagset` objects to use within data stories */
1115
export const skyBackgroundImagesets: BackgroundImageset[] = [
1216
new BackgroundImageset(
1317
"Optical (Terapixel DSS)",

src/components/CreditLogos.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { computed } from "vue";
2323
import { CreditLogosProps } from "../types";
2424
2525
const props = withDefaults(defineProps<CreditLogosProps>(), {
26-
visible: true,
2726
logoSize: "5vmin"
2827
});
2928

src/components/GeolocationButton.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import { GeolocationButtonProps } from "../types";
5959
6060
const props = withDefaults(defineProps<GeolocationButtonProps>(), {
6161
color: "white",
62-
disabled: false,
6362
size: "small",
6463
density: "comfortable",
6564
elevation: "2",
@@ -73,7 +72,6 @@ const props = withDefaults(defineProps<GeolocationButtonProps>(), {
7372
label: "My Location",
7473
trueIcon: "mdi-crosshairs-gps",
7574
falseIcon: "mdi-crosshairs",
76-
backgroundColor: "black",
7775
showPermissions: false,
7876
});
7977

src/composables.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { ref, onMounted, onUnmounted, Ref } from "vue";
22
import screenfull from "screenfull";
33

4+
/**
5+
* A composable that encapsulates fullscreen behavior.
6+
* @returns A reactive variable indicating whether or not fullscreen mode is active
7+
*/
48
export function useFullscreen(): Ref<boolean> {
59
const fullscreenModeActive = ref(false);
610
function update(_event: Event) {
@@ -22,11 +26,20 @@ export function useFullscreen(): Ref<boolean> {
2226
return fullscreenModeActive;
2327
}
2428

29+
/** Interface describing the shape of a browser window */
2530
export interface WindowShape {
2631
width: number;
2732
height: number;
2833
}
34+
35+
/** A default `WindowShape` to use */
2936
export const defaultWindowShape = { width: 1200, height: 900 };
37+
38+
/**
39+
* A composable that encapsulates a changing window shape.
40+
*
41+
* @returns A reactive variable describing the current window shape.
42+
*/
3043
export function useWindowShape() {
3144
const windowShape = ref<WindowShape>(defaultWindowShape);
3245
const resizeObserver = new ResizeObserver(_entries => update());
@@ -51,6 +64,6 @@ export function useWindowShape() {
5164
resizeObserver.unobserve(document.body);
5265
});
5366

54-
return { windowShape, resizeObserver };
67+
return windowShape;
5568
}
5669

src/geolocation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { ref, onMounted } from "vue";
22
import { Capacitor, PermissionState as CapacitorPermissionState } from '@capacitor/core';
33
import { Geolocation, PermissionStatus as CapacitorPermissionStatus, Position, PositionOptions } from "@capacitor/geolocation";
44

5+
/**
6+
* Determine which of two capacitor permission states is 'better'.
7+
* This implementation takes "prompt-with-rationale" to be better than "prompt".
8+
* @returns The 'better' of the two input permission states
9+
*/
510
function betterPermissionState(firstState: CapacitorPermissionState, secondState: CapacitorPermissionState): CapacitorPermissionState {
611
const states: CapacitorPermissionState[] = ["granted", "prompt-with-rationale", "prompt", "denied"];
712
for (const state of states) {
@@ -13,6 +18,13 @@ function betterPermissionState(firstState: CapacitorPermissionState, secondState
1318
}
1419

1520
export type PositionCoords = Position['coords'];
21+
22+
/**
23+
* A composable that encapsulates the current state of the browser
24+
* geolocation position and permission status.
25+
* @param onStartup - Whether or not to query the user's geolocation on startup.
26+
* @returns Reactive state describing the geolocation
27+
*/
1628
export function useGeolocation(onStartup=true) {
1729

1830
const geolocation = ref<PositionCoords | null>(null);

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BackgroundImageset, skyBackgroundImagesets } from "./background";
22
import { useFullscreen, useWindowShape, WindowShape } from "./composables";
33
import { PositionCoords, useGeolocation } from "./geolocation";
4-
import { KeyboardControlSettings } from "./keyboard";
4+
import { KeyPressInfo, KeyboardControlSettings } from "./keyboard";
55
import { useWWTKeyboardControls } from "./wwt-utils";
66

77
import IconButton from "./components/IconButton.vue";
@@ -15,6 +15,7 @@ import Gallery from "./components/Gallery.vue";
1515

1616
export {
1717
BackgroundImageset,
18+
KeyPressInfo,
1819
KeyboardControlSettings,
1920
Gallery,
2021
IconButton,

0 commit comments

Comments
 (0)