-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
title: Aspect Ratio | ||
description: Displays content within a desired ratio. | ||
links: | ||
doc: https://www.radix-ng.com/primitives/components/aspect-ratio | ||
api: https://www.radix-ng.com/primitives/components/aspect-ratio#api-reference | ||
--- | ||
|
||
<ComponentPreview | ||
name="aspect-ratio-demo" | ||
title="Aspect Ratio" | ||
description="A component that displays an image with a 16:9 aspect ratio." | ||
/> | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx shadcn-ng@latest add aspect-ratio | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step>Install the following dependencies:</Step> | ||
|
||
```bash | ||
npm install @radix-ng/primitives | ||
``` | ||
|
||
<Step>Copy and paste the following code into your project.</Step> | ||
|
||
<ComponentSource name="aspect-ratio" /> | ||
|
||
<Step>Update the import paths to match your project setup.</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Usage | ||
|
||
```ts | ||
import { UbAspectRatioDirective } from "@/components/ui/aspect-ratio" | ||
``` | ||
|
||
```html | ||
<div ubAspectRatio [ratio]="16 / 9"> | ||
<img src="..." alt="Image" class="rounded-md object-cover" > | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { UbAspectRatioDirective } from '@/registry/default/ui/aspect-ratio' | ||
|
||
import { NgOptimizedImage } from '@angular/common' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'aspect-ratio-demo-default', | ||
imports: [UbAspectRatioDirective, NgOptimizedImage], | ||
template: ` | ||
<div class="w-96"> | ||
<div ubAspectRatio [ratio]="16 / 9" class="bg-muted"> | ||
<img | ||
ngSrc="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" | ||
alt="Photo by Drew Beamer" | ||
fill | ||
class="h-full w-full rounded-md object-cover" | ||
ngSrcset="640w, 750w, 828w, 1080w, 1200w, 1920w, 2048w, 3840w" | ||
sizes="100vw" | ||
style="position: absolute; height: 100%; width: 100%; inset: 0px; color: transparent;" | ||
/> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
export class AspectRatioDemoDefault { } | ||
|
||
export default AspectRatioDemoDefault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Directive } from '@angular/core' | ||
|
||
import { RdxAspectRatioDirective } from '@radix-ng/primitives/aspect-ratio' | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[ubAspectRatio]', | ||
hostDirectives: [ | ||
{ | ||
directive: RdxAspectRatioDirective, | ||
inputs: ['ratio'], | ||
}, | ||
], | ||
}) | ||
export class UbAspectRatioDirective { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { UbAspectRatioDirective } from '@/registry/new-york/ui/aspect-ratio' | ||
|
||
import { NgOptimizedImage } from '@angular/common' | ||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'aspect-ratio-demo-new-york', | ||
imports: [UbAspectRatioDirective, NgOptimizedImage], | ||
template: ` | ||
<div class="w-96"> | ||
<div ubAspectRatio [ratio]="16 / 9" class="bg-muted"> | ||
<img | ||
ngSrc="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" | ||
alt="Photo by Drew Beamer" | ||
fill | ||
class="h-full w-full rounded-md object-cover" | ||
ngSrcset="640w, 750w, 828w, 1080w, 1200w, 1920w, 2048w, 3840w" | ||
sizes="100vw" | ||
style="position: absolute; height: 100%; width: 100%; inset: 0px; color: transparent;" | ||
/> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
export class AspectRatioDemoNewYork { } | ||
|
||
export default AspectRatioDemoNewYork |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Directive } from '@angular/core' | ||
|
||
import { RdxAspectRatioDirective } from '@radix-ng/primitives/aspect-ratio' | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[ubAspectRatio]', | ||
hostDirectives: [ | ||
{ | ||
directive: RdxAspectRatioDirective, | ||
inputs: ['ratio'], | ||
}, | ||
], | ||
}) | ||
export class UbAspectRatioDirective { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.