Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apps/www/src/content/docs/(overview)/upgrading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ One section per release, newest first, with only the changes that need action
from you. The full record of every release, features and fixes included, is
on [GitHub releases](https://github.com/raystack/apsara/releases).

## Unreleased: `align` takes `start` and `end`

`Headline` and `Container` take `start` and `end` for `align` in place of
`left` and `right`. Both values follow the text direction. `Headline` already
aligned its text this way. In a right-to-left layout, `Container` with
`align="start"` now sits on the right edge, where `align="left"` sat on the
left. Left-to-right layouts look the same.

| Component | Before | After |
|---|---|---|
| `Headline` `align` | `left`, `center`, `right` | `start`, `center`, `end` |
| `Container` `align` | `left`, `center`, `right` | `start`, `center`, `end` |

```tsx
// Before
<Headline align="left">Title</Headline>
<Container size="small" align="right">...</Container>

// After
<Headline align="start">Title</Headline>
<Container size="small" align="end">...</Container>
```

## Unreleased: date filters compare whole days

`DataView`, `DataTable` and `FilterChip` read and compare dates as calendar
Expand Down
10 changes: 5 additions & 5 deletions apps/www/src/content/docs/components/container/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const playground = {
},
align: {
type: 'select',
options: ['left', 'center', 'right'],
options: ['start', 'center', 'end'],
defaultValue: 'center'
},
children: {
Expand All @@ -35,9 +35,9 @@ export const alignDemo = {
type: 'code',
tabs: [
{
name: 'Left Aligned',
name: 'Start Aligned',
code: `
<Container size="small" align="left">
<Container size="small" align="start">
<Text>
Workspace settings control how members join, what they can access, and how billing works. Changes apply to everyone in your organization as soon as you save them.
</Text>
Expand All @@ -53,9 +53,9 @@ export const alignDemo = {
</Container>`
},
{
name: 'Right Aligned',
name: 'End Aligned',
code: `
<Container size="small" align="right">
<Container size="small" align="end">
<Text>
Workspace settings control how members join, what they can access, and how billing works. Changes apply to everyone in your organization as soon as you save them.
</Text>
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/content/docs/components/container/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The `size` prop caps the container's max-width. The default is `none`, which let

### Align

The `align` prop positions the container within its parent: left, center, or right. Default is `center`.
The `align` prop positions the container within its parent: `start`, `center`, or `end`. `start` and `end` follow the text direction, so `start` is the right edge in a right-to-left layout. Default is `center`.

<Demo data={alignDemo} />

Expand Down
4 changes: 2 additions & 2 deletions apps/www/src/content/docs/components/container/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export interface ContainerProps {
size?: 'small' | 'medium' | 'large' | 'none';

/**
* Controls the horizontal alignment of the container
* Controls the horizontal alignment of the container. `start` and `end` follow the text direction.
* @defaultValue "center"
*/
align?: 'left' | 'center' | 'right';
align?: 'start' | 'center' | 'end';

/**
* Renders the container as a different element.
Expand Down
8 changes: 4 additions & 4 deletions apps/www/src/content/docs/components/headline/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const playground = {
},
align: {
type: 'select',
options: ['left', 'center', 'right'],
defaultValue: 'left',
options: ['start', 'center', 'end'],
defaultValue: 'start',
initialValue: 'center'
},
truncate: { type: 'checkbox', defaultValue: false },
Expand All @@ -42,9 +42,9 @@ export const alignDemo = {
type: 'code',
code: `
<Flex direction="column" style={{width:"100%"}} gap={9}>
<Headline size="t2" align="left">Left Aligned</Headline>
<Headline size="t2" align="start">Start Aligned</Headline>
<Headline size="t2" align="center">Center Aligned</Headline>
<Headline size="t2" align="right">Right Aligned</Headline>
<Headline size="t2" align="end">End Aligned</Headline>
</Flex>`
};
export const truncateDemo = {
Expand Down
2 changes: 1 addition & 1 deletion apps/www/src/content/docs/components/headline/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Two weights. `medium` is the default; use `regular` where a headline sits close

### Alignment

`align` sets the text alignment inside the heading's box. Default is `left`.
`align` sets the text alignment inside the heading's box: `start`, `center`, or `end`. `start` and `end` follow the text direction, so `start` is the right edge in a right-to-left layout. Default is `start`.

<Demo data={alignDemo} />

Expand Down
6 changes: 3 additions & 3 deletions apps/www/src/content/docs/components/headline/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export interface HeadlineProps {
| ((props: React.ComponentPropsWithRef<'h2'>) => React.ReactElement);

/**
* Text alignment.
* @default "left"
* Text alignment. `start` and `end` follow the text direction.
* @default "start"
*/
align?: 'left' | 'center' | 'right';
align?: 'start' | 'center' | 'end';

/**
* Enable text truncation with ellipsis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ describe('Container', () => {
});

describe('Alignment', () => {
const alignments = ['left', 'center', 'right'] as const;
const alignments = ['start', 'center', 'end'] as const;

it.each(alignments)('renders %s alignment correctly', align => {
const { container: root } = render(
<Container align={align}>Content</Container>
);
const container = root.firstChild as HTMLElement;
expect(container).toHaveClass(styles[`container-align-${align}`]);
expect(container).toHaveClass(styles[`align-${align}`]);
});

it('defaults to center alignment', () => {
const { container: root } = render(<Container>Content</Container>);
const container = root.firstChild as HTMLElement;
expect(container).toHaveClass(styles['container-align-center']);
expect(container).toHaveClass(styles['align-center']);
});
});

Expand Down
16 changes: 6 additions & 10 deletions packages/react/components/container/container.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,16 @@
max-width: 1145px;
}

/* Alignment variants */
.container-align-left {
margin-left: 0;
margin-right: auto;
.align-start {
margin-inline: 0 auto;
}

.container-align-center {
margin-left: auto;
margin-right: auto;
.align-center {
margin-inline: auto;
}

.container-align-right {
margin-left: auto;
margin-right: 0;
.align-end {
margin-inline: auto 0;
}

@media (max-width: 480px) {
Expand Down
6 changes: 3 additions & 3 deletions packages/react/components/container/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const container = cva(styles.container, {
none: styles['container-none']
},
align: {
left: styles['container-align-left'],
center: styles['container-align-center'],
right: styles['container-align-right']
start: styles['align-start'],
center: styles['align-center'],
end: styles['align-end']
}
},
defaultVariants: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ describe('Headline', () => {
});

describe('Alignment', () => {
const alignments = ['left', 'center', 'right'] as const;
const alignments = ['start', 'center', 'end'] as const;

it.each(alignments)('renders %s alignment correctly', align => {
render(<Headline align={align}>Heading</Headline>);
const heading = screen.getByText('Heading');
expect(heading).toHaveClass(styles[`headline-align-${align}`]);
expect(heading).toHaveClass(styles[`align-${align}`]);
});

it('defaults to left alignment', () => {
it('defaults to start alignment', () => {
render(<Headline>Heading</Headline>);
const heading = screen.getByText('Heading');
expect(heading).toHaveClass(styles['headline-align-left']);
expect(heading).toHaveClass(styles['align-start']);
});
});

Expand Down
6 changes: 3 additions & 3 deletions packages/react/components/headline/headline.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
letter-spacing: var(--rs-letter-spacing-t4);
}

.headline-align-left {
.align-start {
text-align: start;
}

.headline-align-center {
.align-center {
text-align: center;
}

.headline-align-right {
.align-end {
text-align: end;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/react/components/headline/headline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const headline = cva(styles.headline, {
medium: styles['headline-weight-medium']
},
align: {
left: styles['headline-align-left'],
center: styles['headline-align-center'],
right: styles['headline-align-right']
start: styles['align-start'],
center: styles['align-center'],
end: styles['align-end']
},
truncate: {
true: styles['headline-truncate']
Expand All @@ -26,7 +26,7 @@ const headline = cva(styles.headline, {
defaultVariants: {
size: 't2',
weight: 'medium',
align: 'left',
align: 'start',
truncate: false
}
});
Expand Down
Loading