diff --git a/packages/canon/docs/components/Text/Text.tsx b/packages/canon/docs/components/Text/Text.tsx index 9f3dd6ce90..90804b7da7 100644 --- a/packages/canon/docs/components/Text/Text.tsx +++ b/packages/canon/docs/components/Text/Text.tsx @@ -24,7 +24,7 @@ export const Text = ({ style?: React.CSSProperties; }) => { return ( -
+ {children} +
+ ); + }, +); + +Text.displayName = 'Text'; diff --git a/packages/canon/src/components/Text/index.ts b/packages/canon/src/components/Text/index.ts new file mode 100644 index 0000000000..ae1f532b2c --- /dev/null +++ b/packages/canon/src/components/Text/index.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { Text } from './Text'; +export type { TextProps } from './types'; diff --git a/packages/canon/src/components/Text/styles.css b/packages/canon/src/components/Text/styles.css new file mode 100644 index 0000000000..02e2e73392 --- /dev/null +++ b/packages/canon/src/components/Text/styles.css @@ -0,0 +1,26 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.text { + font-family: var(--canon-font-regular); + padding: 0; + margin: 0; + + &.text-body { + font-size: var(--canon-font-size-body); + line-height: 140%; + } +} diff --git a/packages/canon/src/components/Text/types.ts b/packages/canon/src/components/Text/types.ts new file mode 100644 index 0000000000..e63b66e2d9 --- /dev/null +++ b/packages/canon/src/components/Text/types.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2024 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** @public */ +export interface TextProps { + children: React.ReactNode; + variant?: 'subtitle' | 'body' | 'caption' | 'label'; + weight?: 'regular' | 'bold'; +} diff --git a/packages/canon/src/css/components.css b/packages/canon/src/css/components.css index 50978a6710..1bd36990fd 100644 --- a/packages/canon/src/css/components.css +++ b/packages/canon/src/css/components.css @@ -23,3 +23,4 @@ @import '../components/Icon/styles.css'; @import '../components/Checkbox/styles.css'; @import '../components/Table/styles.css'; +@import '../components/Text/styles.css'; diff --git a/packages/canon/src/css/core.css b/packages/canon/src/css/core.css index 95e4b6ce5b..80fe6e78f9 100644 --- a/packages/canon/src/css/core.css +++ b/packages/canon/src/css/core.css @@ -17,6 +17,12 @@ /* Normalize */ @import './normalize.css'; +*, +html, +body { + font-family: var(--canon-font-regular); +} + /* Light theme tokens */ :root { /* Colors */ @@ -91,12 +97,6 @@ /* Container */ --canon-container-max-width: 1200px; --canon-container-padding: 1rem; - - *, - html, - body { - font-family: var(--canon-font-regular); - } } /* Dark theme tokens */