Skip to content

Commit 156b8c3

Browse files
parloughschultek
andauthored
Set up shared package for components and utilities (#13486)
Adds a new `site_shared` package that contains components and other utilities for sharing with [dart-lang/site-www](https://github.com/dart-lang/site-www). - Moved all components that are the same between both sites. - Moved and adapted components that exist on both sites but are slightly different (such as `SiteSwitcher` and `Quiz`) - Moved styled used by moved components. - Moved the markdown rendering setup, which is the same for both sites. - Moved some utilities that are needed by extracted components, such as analytics and code highlighting. --------- Co-authored-by: Kilian Schulte <netlight@schultek.dev>
1 parent 30ed47c commit 156b8c3

150 files changed

Lines changed: 1246 additions & 1077 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/site_shared/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# site_shared
2+
3+
This package is the core library containing
4+
shared logic, UI components, and the design system for
5+
the Dart and Flutter documentation sites.
6+
7+
It provides a centralized location for APIs,
8+
user interface elements, and logic intended for use by
9+
both the `dart.dev` and `docs.flutter.dev` websites.
10+
Using a shared package ensures a consistent design language and
11+
feature set across Dart and Flutter web documentation platforms.
12+
13+
## What's included
14+
15+
The `site_shared` package provides several key capabilities to
16+
build documentation websites using Dart, Jaspr, and Jaspr Content:
17+
18+
- **UI components** (`lib/components`):
19+
Reusable, modular components built for use across documentation pages.
20+
- **Common components** (`lib/components/common`):
21+
Everyday UI elements such as breadcrumbs, buttons, code blocks, and more.
22+
- **Layout components** (`lib/components/layout`):
23+
Structural layout elements like theme switchers,
24+
site switchers, banners, and menu toggles.
25+
- **Interactive components**:
26+
Integrations such as Dartpad (`lib/components/dartpad`),
27+
tutorials, and user client-side feedback tools.
28+
- **Markdown extensions and processors** (`lib/extensions`):
29+
Custom processors that hook into the Dart Markdown parser to
30+
extend its default syntax and behavior, such as `attribute_processor.dart`.
31+
- **Core styles** (`lib/_sass`):
32+
The shared base styles and component-specific SCSS styling.
33+
These resources define the unified visual identity used by both websites.
34+
- **Utilities and builders** (`lib/src`):
35+
Reusable logic for code syntax highlighting (`lib/src/highlight`),
36+
analytics integrations (`lib/src/analytics`),
37+
builders (`lib/src/builders`), and various helper utilities.
38+
39+
## Goals
40+
41+
The primary aims of this shared package are to:
42+
43+
1. Streamline styling and standardize UI component implementation
44+
across our various websites.
45+
1. Prevent code duplication between the
46+
`dart-lang/site-www` and `flutter/website` repositories.
47+
1. Establish a robust codebase that can be
48+
updated, maintained, and improved in a unified way.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:analysis_defaults/analysis.yaml
2+
3+
formatter:
4+
trailing_commas: preserve

packages/site_shared/build.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
builders:
2+
stylesHashBuilder:
3+
import: "package:site_shared/src/builders/styles_hash_builder.dart"
4+
builder_factories: ["stylesHashBuilder"]
5+
build_extensions:
6+
"web/assets/css/main.css":
7+
- "lib/src/style_hash.dart"
8+
auto_apply: dependents
9+
build_to: source
10+
required_inputs:
11+
- ".css"
12+
defaults:
13+
dev_options:
14+
fixed_hash: true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sites/docs/lib/_sass/components/_breadcrumbs.scss renamed to packages/site_shared/lib/_sass/components/_breadcrumbs.scss

File renamed without changes.

sites/docs/lib/_sass/components/_button.scss renamed to packages/site_shared/lib/_sass/components/_button.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ button {
2525
cursor: pointer;
2626

2727
&.filled-button,
28-
&.text-button, &.outlined-button {
28+
&.text-button,
29+
&.outlined-button {
2930
display: flex;
3031
align-items: center;
3132
width: fit-content;

sites/docs/lib/_sass/components/_card.scss renamed to packages/site_shared/lib/_sass/components/_card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
}
174174
}
175175

176-
&.install-card {
176+
&.install-card {
177177
gap: 0.25rem;
178178

179179
.card-leading {

0 commit comments

Comments
 (0)