Skip to content

Commit

Permalink
Merge remote-tracking branch 'utelecon/202308-organize-styles'
Browse files Browse the repository at this point in the history
  • Loading branch information
takemar committed Sep 29, 2023
2 parents e025a3a + 12b8e69 commit be5eedf
Show file tree
Hide file tree
Showing 25 changed files with 223 additions and 512 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"astro-seo": "^0.7.6",
"github-slugger": "^2.0.0",
"mdast": "^3.0.0",
"normalize.css": "^8.0.1",
"rehype-external-links": "^2.1.0",
"sass": "^1.57.1",
"unified": "^10.1.2",
Expand Down
13 changes: 11 additions & 2 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GoogleAnalytics } from "@astrolib/analytics";
import Header from "./Header/index.astro";
import Footer from "./Footer/index.astro";
import Toc from "./Toc.astro";
import "@styles/global.scss";
import "@styles/layout.scss";
import type { MDXLayoutProps, MarkdownHeading } from "astro";
import Author, { Author as AuthorProps } from "./Author.astro";
import Markdown from "@components/utils/Markdown.astro";
Expand Down Expand Up @@ -158,5 +158,14 @@ if (title) {
}
</main>
<Footer lang={lang} support={support} />
</body>
</body><style>
.title {
margin-bottom: 2rem;
padding-bottom: 1rem;
border-bottom: 1px solid $white-gray-dark;
font-size: 2rem;
font-weight: bold;
color: black;
}
</style>
</html>
51 changes: 51 additions & 0 deletions src/styles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# @styles/README

ここでは,このフォルダにあるCSSについて説明します.CSSを加筆する際は,まずこの説明を読んでから作成してください.

このファイルの説明は,CSSに関する基礎知識を前提としています.

このファイルは工事中です.

## `@layouts`および`@components/utils`との棲み分けについて

`@layouts``@components/utils`にある`.astro`ファイルには,そのコンポーネントだけに適用されるCSSを一緒に記述することができます.`@styles`にあるべきCSSと`@layouts``@components/utils`にあるべきCSSの棲み分けは,以下のようになります.

- `@styles`:以下の2種類のCSSを書きます.
- グローバルに適用されるCSS:各ページのMarkdownの範囲に適用されるべきCSS
- 多くのMarkdownで利用されるCSS:`.box``img.medium`などのユーティリティクラス
- `@layouts`:ヘッダーやフッターなど,各ページのMarkdownの範囲外でのみ利用されるCSSを書きます.
- `@components/utils`:各コンポーネントの中でのみ利用されるCSSを書きます.

## `components`以下で定義されているユーティリティクラスについて

`@styles/components`にはユーティリティクラスが定義されています.これらのクラスはグローバルに適用されており,Markdown内で適用することができます.

### `.box`

- `.box`
- `.box--important`
- `.box--alert`
- `strong.box`, `b.box`

### `.cards`

- `.cards`
- `.cards + h2`

### `img`

- `img.large`, `img.medium`, `img.small`
- `img.inline`
- `img.logo`
- `img.center`
- `img.border`
- `img.shadow`

### `figure`

- `figure`
- `figcaption`

### `.gallery`


File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/styles/color.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./components/cayman/variables.scss";
@import "./cayman/variables.scss";

$gray: #777777;
$black-gray: #212121;
Expand Down
3 changes: 2 additions & 1 deletion src/styles/components/box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
}
}

strong.box, b.box {
strong.box,
b.box {
@include box--bold;
}
6 changes: 4 additions & 2 deletions src/styles/components/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
padding: 0;

& > li {
/* for IE11 */ display: block;
/* for IE11 */
display: block;
display: contents;
}

& > a, & > li > a {
& > a,
& > li > a {
display: block;
border: 1px solid $black-gray;
border-left: 4px solid $heading-color;
Expand Down
22 changes: 18 additions & 4 deletions src/styles/components/code.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
code {
padding: 0.2em 0.4em;
font-size: 0.9em;
color: black;
background-color: $white-gray-light;
padding: 0.2em 0.4em;
font-size: 0.9em;
color: black;
background-color: $white-gray-light;
}

code,
pre {
&,
&:lang(en) {
hyphens: none;
}
}

code em {
font-style: normal;
font-weight: bold;
background-color: yellow;
}
4 changes: 4 additions & 0 deletions src/styles/components/footnotes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.footnotes {
padding-top: 0.5em;
border-top: 2px solid $gray;
}
3 changes: 2 additions & 1 deletion src/styles/components/link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
:visited {
color: $visited-color;
}
:link, :visited {
:link,
:visited {
text-decoration: none;
&:hover {
text-decoration: underline;
Expand Down
38 changes: 38 additions & 0 deletions src/styles/components/lists.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@media (max-width: 640px) {
ul,
ol {
padding-left: 20px;
}
}

@counter-style decimal-bracket {
system: extends decimal;
prefix: "[";
suffix: "] ";
}

ol.bracket {
list-style: decimal-bracket;
}

// remove user agent stylesheet against <p> element inside <li>
li > p,
.box > p,
.box--alert > p,
details > p {
margin: 0;
}

ul.gap,
ol.gap {
& > li {
margin-top: 1em;
margin-bottom: 1em;
}
& > li:first-child {
margin-top: 0;
}
& > li:last-child {
margin-bottom: 0;
}
}
45 changes: 3 additions & 42 deletions src/styles/utils.scss → src/styles/components/mfa.scss
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
.alert {
color: $red;
}

.center {
text-align: center;
}

.iframe-container {
position:relative;
width: 100%;
height: 0;
--aspect-ratio: 56.25%;
padding-bottom: var(--aspect-ratio);
> iframe {
position: absolute;
width: 100%;
height: 100%;
}
}

ul.gap, ol.gap {
&>li {
margin-top: 1em;
margin-bottom: 1em;
}
&>li:first-child {
margin-top: 0;
}
&>li:last-child {
margin-bottom: 0;
}
}

// transported from mfa.scss
ol.mfa-initial-procedure {
& > li {
counter-increment: mfa-initial-main;
Expand All @@ -57,13 +22,9 @@ ul.mfa-initial-procedure {
list-style-position: inside;
text-indent: -1em;
&::marker {
content:
counters(mfa-initial-main, "-")
"-"
counters(mfa-initial-sub-headline, "-", upper-latin)
"-"
counters(mfa-initial-sub-procedure, "-")
". ";
content: counters(mfa-initial-main, "-") "-"
counters(mfa-initial-sub-headline, "-", upper-latin) "-"
counters(mfa-initial-sub-procedure, "-") ". ";
}
ol {
counter-reset: list-item;
Expand Down
7 changes: 7 additions & 0 deletions src/styles/components/summary.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
summary {
cursor: pointer;
color: $link-color;
&:hover {
text-decoration: underline;
}
}
3 changes: 3 additions & 0 deletions src/styles/components/table.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
table {
border-collapse: collapse;
}
File renamed without changes.
20 changes: 20 additions & 0 deletions src/styles/components/utils.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.alert {
color: $red;
}

.center {
text-align: center;
}

.iframe-container {
position: relative;
width: 100%;
height: 0;
--aspect-ratio: 56.25%;
padding-bottom: var(--aspect-ratio);
> iframe {
position: absolute;
width: 100%;
height: 100%;
}
}
3 changes: 0 additions & 3 deletions src/styles/global.scss

This file was deleted.

11 changes: 3 additions & 8 deletions src/styles/layout.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "normalize";
@import "../../node_modules/normalize.css/normalize.css";
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap");

* {
Expand All @@ -11,10 +11,5 @@ html {
line-height: 1.5;
}

table {
border-collapse: collapse;
}

@import "components/cayman/jekyll-theme-cayman";
@import "layout/main";
@import "components/box";
@import "cayman/jekyll-theme-cayman";
@import "main";
Loading

0 comments on commit be5eedf

Please sign in to comment.