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}
); diff --git a/packages/canon/docs/components/Text/styles.css b/packages/canon/docs/components/Text/styles.css index cbb2b88edb..0092625c27 100644 --- a/packages/canon/docs/components/Text/styles.css +++ b/packages/canon/docs/components/Text/styles.css @@ -14,7 +14,7 @@ * limitations under the License. */ -.text { +.sb-text { font-family: 'Geist', sans-serif; font-size: 16px; line-height: 28px; diff --git a/packages/canon/docs/components/Title/Title.tsx b/packages/canon/docs/components/Title/Title.tsx index 056ccfc14d..59fefad8f9 100644 --- a/packages/canon/docs/components/Title/Title.tsx +++ b/packages/canon/docs/components/Title/Title.tsx @@ -31,7 +31,7 @@ export const Title = ({ if (type === 'h3') Component = 'h3'; return React.createElement(Component, { - className: `title ${type}`, + className: `sb-title ${type}`, style, children, }); diff --git a/packages/canon/docs/components/Title/styles.css b/packages/canon/docs/components/Title/styles.css index a8d00e2af5..cfb0e6e379 100644 --- a/packages/canon/docs/components/Title/styles.css +++ b/packages/canon/docs/components/Title/styles.css @@ -14,7 +14,7 @@ * limitations under the License. */ -.title { +.sb-title { font-family: 'Geist', sans-serif; margin: 0; font-weight: 500; diff --git a/packages/canon/src/components/Text/Text.stories.tsx b/packages/canon/src/components/Text/Text.stories.tsx new file mode 100644 index 0000000000..5736cd1973 --- /dev/null +++ b/packages/canon/src/components/Text/Text.stories.tsx @@ -0,0 +1,33 @@ +/* + * 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. + */ + +import type { Meta, StoryObj } from '@storybook/react'; +import { Text } from './Text'; + +const meta = { + title: 'Components/Text', + component: Text, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + children: + ' Lorem ipsum dolor sit amet consectetur. Nec arcu vel lacus magna adipiscing nisi mauris tortor viverra. Enim rhoncus quisque consectetur ligula diam ac lacus massa. Id interdum id pellentesque justo ut massa nibh amet. Odio massa in scelerisque tortor massa integer purus amet enim. Eros sit neque nullam facilisis. Purus massa dignissim aliquet purus eu in. Urna consequat ullamcorper arcu amet dictumst. Commodo praesent turpis fringilla tristique congue volutpat in. Nulla in nulla ultrices lacus. In ultrices id tellus ut. Semper duis in in non proin et pulvinar. Sit amet vulputate lorem sit ipsum quis amet pulvinar ultricies. Imperdiet enim molestie habitant eget. Aenean mollis aenean dolor sodales tempus blandit.', + }, +}; diff --git a/packages/canon/src/components/Text/Text.tsx b/packages/canon/src/components/Text/Text.tsx new file mode 100644 index 0000000000..6567eb989d --- /dev/null +++ b/packages/canon/src/components/Text/Text.tsx @@ -0,0 +1,43 @@ +/* + * 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. + */ + +import React, { forwardRef } from 'react'; +import { TextProps } from './types'; + +export const Text = forwardRef( + (props, ref) => { + const { + children, + variant = 'body', + weight = 'regular', + ...restProps + } = props; + + 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 */