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

Cleanup: Preload FontAwesome, fix comment grammar, audit NPM packages #189

Merged
merged 3 commits into from
Jul 4, 2022
Merged
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
7 changes: 7 additions & 0 deletions _layouts/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
{% seo %}

{%- comment -%}
The FontAwesome stylesheet is injected by Primer Spec to defer
loading. However, we can mitigate the icon-flashing by requesting
the browser to preload the stylesheet asynchronously asap.
{%- endcomment -%}
<link rel="preload" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" as="style" crossorigin="anonymous" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr">

{%- if site.favicon %}
<link rel="icon" href="{{ site.favicon | relative_url }}">
{%- endif %}
Expand Down
64 changes: 32 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src_js/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import PrimerSpec from './components/PrimerSpec';
import Config from './Config';
import { updateTheme } from './subthemes';

/**
* The entry point to the Primer Spec JS.
*/
function main() {
const anchors = new AnchorJS();
anchors.add('h1');
Expand Down
2 changes: 1 addition & 1 deletion src_js/utils/hooks/print.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from 'preact/hooks';

/**
* Returns a stateful boolean representing if a print-event is in progress
* Return a stateful boolean representing if a print-event is in progress
* (between beforeprint and afterprint).
*/
export function usePrintInProgress(): boolean {
Expand Down
5 changes: 5 additions & 0 deletions src_js/utils/hooks/usePrefersDarkMode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { useEffect, useState } from 'preact/hooks';

/**
* Return a stateful boolean that describes whether the user's OS settings
* indicate a preference for light-themes or dark-themes. This preference is
* used when the subtheme mode is set to 'system'.
*/
export default function usePrefersDarkMode(): boolean {
const [prefersDarkMode, setPrefersDarkMode] = useState(
window.matchMedia('(prefers-color-scheme: dark)').matches,
Expand Down
4 changes: 4 additions & 0 deletions src_js/utils/hooks/useSmallScreen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useLayoutEffect, useState } from 'preact/hooks';
import isSmallScreen from '../isSmallScreen';

/**
* Return a stateful boolean indicating whether the viewer's screen width is
* 'small' (as defined by `isSmallScreen()`).
*/
export default function useSmallScreen(): boolean {
const [is_small_screen, setIsSmallScreen] = useState(isSmallScreen());
useLayoutEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src_js/utils/hooks/useWindowLoaded.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'preact/hooks';

/**
* Returns a stateful boolean that indicates whether all resources on the page
* Return a stateful boolean that indicates whether all resources on the page
* have been downloaded (and the 'load' event will fire / has fired on the
* window).
*/
Expand Down
2 changes: 1 addition & 1 deletion src_js/utils/isSmallScreen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Returns a boolean indicating whether the viewer's screen width is
* Return a boolean indicating whether the viewer's screen width is
* smaller than 900px.
*/
export default function isSmallScreen(): boolean {
Expand Down