Skip to content

Commit c674dcd

Browse files
committed
fix(styles): typography use latest CSS
1 parent 975eb48 commit c674dcd

27 files changed

+451
-745
lines changed

.changeset/calm-taxes-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@spectrum-web-components/styles': patch
3+
---
4+
5+
Remove unnecessary system theme references to reduce complexity for components that don't need the additional mapping layer.

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ parameters:
1414
# 3. Commit this change to the PR branch where the changes exist.
1515
current_golden_images_hash:
1616
type: string
17-
default: 728676ad885db988eb369dac901e9904bf6b79d2
17+
default: b3342a5f378ee473443510bcbd28f80c10e29460
1818
wireit_cache_name:
1919
type: string
2020
default: wireit

packages/card/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
"@spectrum-web-components/checkbox": "1.6.0",
7070
"@spectrum-web-components/divider": "1.6.0",
7171
"@spectrum-web-components/icons-workflow": "1.6.0",
72-
"@spectrum-web-components/shared": "1.6.0",
73-
"@spectrum-web-components/styles": "1.6.0"
72+
"@spectrum-web-components/shared": "1.6.0"
7473
},
7574
"devDependencies": {
7675
"@spectrum-css/card": "11.1.0"

packages/card/src/Card.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import '@spectrum-web-components/checkbox/sp-checkbox.js';
3434
import '@spectrum-web-components/popover/sp-popover.js';
3535
import '@spectrum-web-components/divider/sp-divider.js';
3636
import cardStyles from './card.css.js';
37-
import headingStyles from '@spectrum-web-components/styles/heading.js';
38-
import detailStyles from '@spectrum-web-components/styles/detail.js';
3937

4038
/**
4139
* @element sp-card
@@ -62,7 +60,7 @@ export class Card extends LikeAnchor(
6260
)
6361
) {
6462
public static override get styles(): CSSResultArray {
65-
return [headingStyles, detailStyles, cardStyles];
63+
return [cardStyles];
6664
}
6765

6866
@property()
@@ -209,10 +207,7 @@ export class Card extends LikeAnchor(
209207

210208
protected get renderHeading(): TemplateResult {
211209
return html`
212-
<div
213-
class="title spectrum-Heading spectrum-Heading--sizeXS"
214-
id="heading"
215-
>
210+
<div class="title" id="heading">
216211
<slot name="heading">${this.heading}</slot>
217212
</div>
218213
`;
@@ -263,7 +258,7 @@ export class Card extends LikeAnchor(
263258

264259
private get renderSubtitleAndDescription(): TemplateResult {
265260
return html`
266-
<div class="subtitle spectrum-Detail spectrum-Detail--sizeS">
261+
<div class="subtitle">
267262
<slot name="subheading">${this.subheading}</slot>
268263
</div>
269264
<slot name="description"></slot>

packages/card/src/card.css

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ OF ANY KIND, either express or implied. See the License for the specific languag
1010
governing permissions and limitations under the License.
1111
*/
1212

13-
@import url('./spectrum-card.css');
14-
@import url('./card-overrides.css');
13+
@import url("./spectrum-card.css");
14+
@import url("./card-overrides.css");
1515

16-
:host([href]:not([href=''])) {
16+
:host([href]:not([href=""])) {
1717
cursor: pointer;
1818
}
1919

@@ -27,29 +27,26 @@ governing permissions and limitations under the License.
2727
flex-grow: 0;
2828
}
2929

30-
:host([dir='ltr']) .action-button {
30+
:host([dir="ltr"]) .action-button {
3131
margin-left: auto;
3232
}
3333

34-
:host([dir='rtl']) .action-button {
34+
:host([dir="rtl"]) .action-button {
3535
margin-right: auto;
3636
}
3737

38-
/* The description slot has a psuedo-element that also needs to receive the font styling.
38+
/* The description slot has a psuedo-element that also needs to receive the font styling.
3939
We need to add the declaration to the slot as well */
40-
slot[name='description'] {
41-
font-size: var(
42-
--spectrum-card-subtitle-text-size,
43-
var(--spectrum-font-size-50)
44-
);
40+
slot[name="description"] {
41+
font-size: var(--spectrum-card-subtitle-text-size, var(--spectrum-font-size-50));
4542
}
4643

4744
#preview + #cover-photo {
4845
display: none;
4946
}
5047

5148
#cover-photo ::slotted(*),
52-
:host(:not([variant='quiet'])) #preview ::slotted(*) {
49+
:host(:not([variant="quiet"])) #preview ::slotted(*) {
5350
width: 100%;
5451
display: block;
5552

@@ -59,7 +56,7 @@ slot[name='description'] {
5956
object-fit: cover;
6057
}
6158

62-
:host(:not([variant='gallery'])) #preview ::slotted(*) {
59+
:host(:not([variant="gallery"])) #preview ::slotted(*) {
6360
height: 100%;
6461
}
6562

@@ -81,16 +78,18 @@ sp-popover {
8178
}
8279

8380
/**
84-
* Allow that the heading element will take specified use of the available width whether
81+
* Allow that the heading element will take specified use of the available width whether
8582
* "actions" are supplied to the element or not.
8683
**/
8784
.title {
8885
width: var(--spectrum-card-title-width);
8986
}
9087

9188
.subtitle {
92-
/* Override until https://github.com/adobe/spectrum-css/issues/1054 is fixed */
93-
text-transform: none;
89+
font-family: var(--spectrum-sans-font-family-stack);
90+
font-size: var(--spectrum-detail-size-s);
91+
font-weight: var(--spectrum-detail-sans-serif-font-weight);
92+
line-height: var(--spectrum-detail-line-height);
9493
}
9594

9695
:host:before,

projects/documentation/src/components/styles.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ governing permissions and limitations under the License.
1515
@import '@spectrum-web-components/styles/tokens/spectrum/custom-vars.css';
1616
@import '@spectrum-web-components/styles/tokens/spectrum/system-theme-bridge.css';
1717
@import '@spectrum-web-components/styles/src/spectrum-heading.css';
18-
@import '@spectrum-web-components/styles/src/heading-overrides.css';
1918
@import '@spectrum-web-components/styles/src/spectrum-body.css';
20-
@import '@spectrum-web-components/styles/src/body-overrides.css';
2119
@import '@spectrum-web-components/styles/src/spectrum-code.css';
22-
@import '@spectrum-web-components/styles/src/code-overrides.css';
2320
@import '@spectrum-web-components/opacity-checkerboard/src/spectrum-opacity-checkerboard.css';
2421
@import './inline-alert.css';
2522
@import './fonts.css';

scripts/spectrum-vars.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,12 @@ const processCSS = async (
116116

117117
const processTypography = async (
118118
baseSrcPath,
119-
overridesSrcPath,
120119
dstPath,
121120
identifier,
122121
from,
123122
usedVariables = undefined
124123
) => {
125-
const baseData = fs.readFileSync(baseSrcPath, 'utf8');
126-
const overridesData = fs.readFileSync(overridesSrcPath, 'utf8');
127-
const data = baseData + overridesData;
124+
const data = fs.readFileSync(baseSrcPath, 'utf8');
128125
const result = await processCSSData(data, identifier, from, usedVariables);
129126
fs.writeFileSync(dstPath, result, 'utf8');
130127

@@ -214,20 +211,12 @@ async function processSpectrumVars() {
214211
'typography',
215212
'dist'
216213
);
217-
const baseSrcPath = path.join(typographyPath, 'index-base.css');
218-
const overridesSrcPath = path.join(typographyPath, 'index-theme.css');
214+
const baseSrcPath = path.join(typographyPath, 'index.css');
219215
const dstPath = path.resolve(
220216
path.join(__dirname, '..', 'tools', 'styles', 'typography.css')
221217
);
222218
console.log(`processing typography`);
223-
processes.push(
224-
processTypography(
225-
baseSrcPath,
226-
overridesSrcPath,
227-
dstPath,
228-
'typography'
229-
)
230-
);
219+
processes.push(processTypography(baseSrcPath, dstPath, 'typography'));
231220
}
232221

233222
await Promise.all(processes).then(() => {

tasks/process-spectrum.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,18 @@ async function processComponent(componentPath) {
162162
* @type { import('./spectrum-css-converter').SpectrumCSSConverter}
163163
*/
164164
for await (const conversion of conversions) {
165-
// The default package file is index.css but index-base.css contains the base styles compatible with theme switching.
166-
let sourcePath = require
167-
.resolve(conversion.inPackage)
168-
.replace('index.css', 'index-base.css');
169-
165+
// The default package file is index.css
166+
const sourcePath = require.resolve(conversion.inPackage);
170167
let sourceCSS = '';
171168

172-
// try to find the index-base.css file
173-
try {
174-
sourceCSS = fs.readFileSync(sourcePath, 'utf-8');
175-
} catch (error) {
169+
// index-base.css contains the base styles compatible with theme switching
170+
if (fs.existsSync(sourcePath.replace('index.css', 'index-base.css'))) {
171+
sourceCSS = fs.readFileSync(
172+
sourcePath.replace('index.css', 'index-base.css'),
173+
'utf-8'
174+
);
175+
} else {
176176
// if failed, try to find the index.css file
177-
sourcePath = require.resolve(conversion.inPackage);
178177
sourceCSS = fs.readFileSync(sourcePath, 'utf-8');
179178
}
180179

tools/styles/body.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,7 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
import baseStyles from './src/spectrum-base.css.js';
14-
import langBaseStyles from './src/spectrum-lang.css.js';
15-
import langOverrides from './src/lang-overrides.css.js';
16-
import bodyBaseStyles from './src/spectrum-body.css.js';
17-
import bodyOverrides from './src/body-overrides.css.js';
18-
19-
import { css } from 'lit';
20-
21-
// bodyStyles is a combination of bodyBaseStyles and bodyOverrides
22-
const bodyStyles = css`
23-
${bodyBaseStyles}
24-
${bodyOverrides}
25-
`;
26-
27-
// langStyles is a combination of langBaseStyles and langOverrides
28-
const langStyles = css`
29-
${langBaseStyles}
30-
${langOverrides}
31-
`;
14+
import langStyles from './src/spectrum-lang.css.js';
15+
import bodyStyles from './src/spectrum-body.css.js';
3216

3317
export default [baseStyles, langStyles, bodyStyles];

tools/styles/code.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,7 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
import baseStyles from './src/spectrum-base.css.js';
14-
import langBaseStyles from './src/spectrum-lang.css.js';
15-
import langOverrides from './src/lang-overrides.css.js';
16-
import codeBaseStyles from './src/spectrum-code.css.js';
17-
import codeOverrides from './src/code-overrides.css.js';
18-
19-
import { css } from 'lit';
20-
21-
const langStyles = css`
22-
${langBaseStyles}
23-
${langOverrides}
24-
`;
25-
26-
const codeStyles = css`
27-
${codeBaseStyles}
28-
${codeOverrides}
29-
`;
14+
import langStyles from './src/spectrum-lang.css.js';
15+
import codeStyles from './src/spectrum-code.css.js';
3016

3117
export default [baseStyles, langStyles, codeStyles];

0 commit comments

Comments
 (0)