forked from refinedev/refine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add UrlField docs * update doc example * Update documentation/docs/guides-and-concepts/fields/url.md Co-authored-by: Ömer Faruk APLAK <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
id: url | ||
title: Url | ||
--- | ||
|
||
This field lets you embed a link. It uses [Ant Design's <Typography.Link\>](https://ant.design/components/typography/) component. You can pass a url in its `value` prop. And you can show a text in its place by passing any `children`. | ||
|
||
## Usage | ||
|
||
Let's see how to use `<UrlField>` with an example: | ||
|
||
```tsx title="pages/posts/list.tsx" | ||
import * as React from "react"; | ||
|
||
import { List, Table, useTable, UrlField } from "@pankod/refine"; | ||
|
||
export const PostList: React.FC = () => { | ||
const { tableProps } = useTable<IPost>(); | ||
|
||
return ( | ||
<List> | ||
<Table<IPost> {...tableProps} rowKey="id"> | ||
<Table.Column<IPost> | ||
dataIndex="title" | ||
title="Title" | ||
key="title" | ||
/> | ||
<Table.Column<IPost> | ||
dataIndex={["image", "0", "url"]} | ||
title={"Image"} | ||
key="image" | ||
render={(value: string) => <UrlField value={value} />} | ||
/> | ||
</Table> | ||
</List> | ||
); | ||
}; | ||
``` | ||
|
||
```ts title="interfaces/index.d.ts" | ||
interface IPost { | ||
title: string; | ||
image: IImage[]; | ||
} | ||
|
||
interface IImage { | ||
url: string; | ||
} | ||
``` | ||
|
||
## API Reference | ||
|
||
### Properties | ||
|
||
| Property | Description | Type | | ||
| -------- | ---------------------------- | ----------- | | ||
| value | Url for link to reference to | `string` | | ||
| children | What to show instead of url | `ReactNode` | |
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