Skip to content

Commit 37aea4e

Browse files
committed
Experiment with a structure for shared styles
Regenerate workflow
1 parent 65d653b commit 37aea4e

File tree

8 files changed

+182
-6
lines changed

8 files changed

+182
-6
lines changed

.github/workflows/dart.yml

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ jobs:
3939
- name: mono_repo self validate
4040
run: dart pub global run mono_repo generate --validate
4141
job_002:
42-
name: "analyzer_and_format; Dart 3.5.0; PKGS: pkgs/analysis_defaults, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
42+
name: "analyzer_and_format; Dart 3.5.0; PKGS: pkgs/analysis_defaults, pkgs/dash_design, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
4343
runs-on: ubuntu-latest
4444
steps:
4545
- name: Cache Pub hosted dependencies
4646
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
4747
with:
4848
path: "~/.pub-cache/hosted"
49-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
49+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
5050
restore-keys: |
51-
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/excerpter-pkgs/inject_dartpad
51+
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad
5252
os:ubuntu-latest;pub-cache-hosted;sdk:3.5.0
5353
os:ubuntu-latest;pub-cache-hosted
5454
os:ubuntu-latest
@@ -72,6 +72,19 @@ jobs:
7272
run: dart analyze --fatal-infos .
7373
if: "always() && steps.pkgs_analysis_defaults_pub_upgrade.conclusion == 'success'"
7474
working-directory: pkgs/analysis_defaults
75+
- id: pkgs_dash_design_pub_upgrade
76+
name: pkgs/dash_design; dart pub upgrade
77+
run: dart pub upgrade
78+
if: "always() && steps.checkout.conclusion == 'success'"
79+
working-directory: pkgs/dash_design
80+
- name: "pkgs/dash_design; dart format --output=none --set-exit-if-changed ."
81+
run: "dart format --output=none --set-exit-if-changed ."
82+
if: "always() && steps.pkgs_dash_design_pub_upgrade.conclusion == 'success'"
83+
working-directory: pkgs/dash_design
84+
- name: "pkgs/dash_design; dart analyze --fatal-infos ."
85+
run: dart analyze --fatal-infos .
86+
if: "always() && steps.pkgs_dash_design_pub_upgrade.conclusion == 'success'"
87+
working-directory: pkgs/dash_design
7588
- id: pkgs_excerpter_pub_upgrade
7689
name: pkgs/excerpter; dart pub upgrade
7790
run: dart pub upgrade
@@ -99,16 +112,16 @@ jobs:
99112
if: "always() && steps.pkgs_inject_dartpad_pub_upgrade.conclusion == 'success'"
100113
working-directory: pkgs/inject_dartpad
101114
job_003:
102-
name: "analyzer_and_format; Dart dev; PKGS: pkgs/analysis_defaults, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
115+
name: "analyzer_and_format; Dart dev; PKGS: pkgs/analysis_defaults, pkgs/dash_design, pkgs/excerpter, pkgs/inject_dartpad; `dart format --output=none --set-exit-if-changed .`, `dart analyze --fatal-infos .`"
103116
runs-on: ubuntu-latest
104117
steps:
105118
- name: Cache Pub hosted dependencies
106119
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
107120
with:
108121
path: "~/.pub-cache/hosted"
109-
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/analysis_defaults-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
122+
key: "os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad;commands:format-analyze"
110123
restore-keys: |
111-
os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/analysis_defaults-pkgs/excerpter-pkgs/inject_dartpad
124+
os:ubuntu-latest;pub-cache-hosted;sdk:dev;packages:pkgs/analysis_defaults-pkgs/dash_design-pkgs/excerpter-pkgs/inject_dartpad
112125
os:ubuntu-latest;pub-cache-hosted;sdk:dev
113126
os:ubuntu-latest;pub-cache-hosted
114127
os:ubuntu-latest
@@ -132,6 +145,19 @@ jobs:
132145
run: dart analyze --fatal-infos .
133146
if: "always() && steps.pkgs_analysis_defaults_pub_upgrade.conclusion == 'success'"
134147
working-directory: pkgs/analysis_defaults
148+
- id: pkgs_dash_design_pub_upgrade
149+
name: pkgs/dash_design; dart pub upgrade
150+
run: dart pub upgrade
151+
if: "always() && steps.checkout.conclusion == 'success'"
152+
working-directory: pkgs/dash_design
153+
- name: "pkgs/dash_design; dart format --output=none --set-exit-if-changed ."
154+
run: "dart format --output=none --set-exit-if-changed ."
155+
if: "always() && steps.pkgs_dash_design_pub_upgrade.conclusion == 'success'"
156+
working-directory: pkgs/dash_design
157+
- name: "pkgs/dash_design; dart analyze --fatal-infos ."
158+
run: dart analyze --fatal-infos .
159+
if: "always() && steps.pkgs_dash_design_pub_upgrade.conclusion == 'success'"
160+
working-directory: pkgs/dash_design
135161
- id: pkgs_excerpter_pub_upgrade
136162
name: pkgs/excerpter; dart pub upgrade
137163
run: dart pub upgrade

pkgs/dash_design/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2024, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:analysis_defaults/analysis.yaml

pkgs/dash_design/lib/styles.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// styles.scss:
6+
///
7+
/// Incorporates all styles and CSS custom properties (variables)
8+
/// from the dash_design package.
9+
///
10+
/// Variables are added at the `:root` (the `html` element),
11+
/// and dark mode variables are set if `data-theme=dark`
12+
/// is added to the `html` element.
13+
14+
@use 'styles/variables';
15+
16+
$google-site: false !default;
17+
18+
:root {
19+
@include variables.shared;
20+
21+
@include variables.light-theme;
22+
23+
&[data-theme=dark] {
24+
@include variables.dark-theme;
25+
}
26+
27+
@if $google-site {
28+
@include variables.google-overrides;
29+
}
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// CSS custom properties (variables) to be used across all themes.
6+
@mixin shared {
7+
// Shared typography style variables.
8+
9+
/// Used for body text and smaller UI elements, like labels.
10+
--dash-default-font-family: 'Roboto', sans-serif;
11+
12+
/// Used for headlines, titles, and larger UI elements.
13+
--dash-display-font-family: 'Roboto', sans-serif;
14+
15+
/// Used for monospace text, such as code blocks.
16+
--dash-mono-font-family: 'Roboto Mono', 'Source Code Pro', 'Cascadia Mono', 'JetBrains Mono', monospace;
17+
18+
/// Used for icons, such as the magnifying glass for search.
19+
--dash-symbol-font-family: 'Material Symbols', 'Material Symbols Outlined';
20+
}
21+
22+
/// CSS custom properties (variables) to be used for a light theme.
23+
@mixin light-theme {
24+
/// The default text color, used for body text.
25+
--dash-on-background-text-color: #212121;
26+
}
27+
28+
/// CSS custom properties (variables) to be used for a dark theme.
29+
@mixin dark-theme {
30+
--dash-on-background-text-color: #e0e0e0;
31+
}
32+
33+
/// Styles that can only be used by Google sites,
34+
/// such as enabling the Google Sans font families.
35+
///
36+
/// These overrides should be included after all other variables are defined.
37+
@mixin google-overrides() {
38+
// Non-Google sites, such as self-hosted API docs,
39+
// can't use Google Sans or Google Symbols.
40+
--dash-default-font-family: 'Google Sans Text', 'Google Sans', 'Roboto', sans-serif;
41+
--dash-display-font-family: 'Google Sans', 'Google Sans Text', 'Roboto', sans-serif;
42+
--dash-mono-font-family: 'Google Sans Mono', 'Roboto Mono', 'Source Code Pro', 'Cascadia Mono', 'JetBrains Mono', monospace;
43+
--dash-symbol-font-family: 'Google Symbols', 'Material Symbols', 'Material Symbols Outlined';
44+
}

pkgs/dash_design/mono_pkg.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sdk:
2+
- pubspec
3+
- dev
4+
5+
stages:
6+
- analyzer_and_format:
7+
- group:
8+
- format
9+
- analyze: --fatal-infos .

pkgs/dash_design/pubspec.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: dash_design
2+
description: Shared styles for Dart and Flutter websites.
3+
version: 0.0.1-wip
4+
publish_to: none
5+
repository: https://github.com/dart-lang/site-shared/tree/main/pkgs/dash_design
6+
7+
environment:
8+
sdk: ^3.5.0
9+
10+
dev_dependencies:
11+
analysis_defaults:
12+
path: ../analysis_defaults
13+
path: ^1.9.0
14+
sass: ^1.79.4
15+
test: ^1.25.8

pkgs/dash_design/test/style_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:isolate';
6+
7+
import 'package:path/path.dart' as path;
8+
import 'package:sass/sass.dart' as sass;
9+
import 'package:test/test.dart';
10+
11+
void main() {
12+
test('Can build styles.scss file', () {
13+
final compileResult = sass.compileToResult(_stylesPath!);
14+
expect(compileResult.css, contains('--dash-default-font-family'));
15+
});
16+
}
17+
18+
String? get _stylesPath {
19+
final packageUri = Uri.parse('package:dash_design/styles.scss');
20+
final resolvedUri = Isolate.resolvePackageUriSync(packageUri);
21+
if (resolvedUri == null) return null;
22+
if (!resolvedUri.isScheme('file')) return null;
23+
return path.fromUri(resolvedUri);
24+
}

0 commit comments

Comments
 (0)