Skip to content

Commit

Permalink
Merge pull request #538 from icflorescu/next
Browse files Browse the repository at this point in the history
Update dev deps, add another row action cell example
  • Loading branch information
icflorescu authored Jan 31, 2024
2 parents 0b6c42b + f8a4014 commit 6165045
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ const showModal = ({ company, action }: { company: Company; action: 'view' | 'ed
action === 'view'
? 'Showing company information'
: action === 'edit'
? 'Editing company information'
: 'Deleting company',
? 'Editing company information'
: 'Deleting company',
children: (
<Stack>
<Text>
{action === 'view'
? 'Here’s where you could show more information...'
: action === 'edit'
? 'Here’s where you could put an edit form...'
: 'Here’s where you could ask for confirmation before deleting...'}
? 'Here’s where you could put an edit form...'
: 'Here’s where you could ask for confirmation before deleting...'}
</Text>
<Grid gutter="xs">
<GridCol span={2}>ID</GridCol>
Expand All @@ -39,7 +39,7 @@ const showModal = ({ company, action }: { company: Company; action: 'view' | 'ed
};

export function RowActionsCellExample() {
// example-start
// example-start default
return (
<DataTable
withTableBorder
Expand Down Expand Up @@ -86,3 +86,59 @@ export function RowActionsCellExample() {
);
// example-end
}

export function RowActionsCellExampleConstrainWidth() {
return (
// example-start constrain-width
<DataTable
withTableBorder
withColumnBorders
columns={[
// example-skip other columns
{ accessor: 'name' },
{ accessor: 'city' },
{ accessor: 'state' },
// example-resume
{
accessor: 'actions',
title: <Box mr={6}>Actions</Box>,
width: '0%', // 👈 set width to 0%
textAlign: 'right',
render: (company) => (
// 👇 make sure the actions don't wrap
<Group gap={4} wrap="nowrap">
{/* example-skip action icons */}
<ActionIcon
size="sm"
variant="subtle"
color="green"
onClick={() => showModal({ company, action: 'view' })}
>
<IconEye size={16} />
</ActionIcon>
<ActionIcon
size="sm"
variant="subtle"
color="blue"
onClick={() => showModal({ company, action: 'edit' })}
>
<IconEdit size={16} />
</ActionIcon>
<ActionIcon
size="sm"
variant="subtle"
color="red"
onClick={() => showModal({ company, action: 'delete' })}
>
<IconTrash size={16} />
</ActionIcon>
{/* example-resume */}
</Group>
),
},
]}
records={records}
/>
// example-end
);
}
18 changes: 15 additions & 3 deletions app/examples/row-actions-cell/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { Code } from '@mantine/core';
import type { Route } from 'next';
import { MANTINE_LINK } from '~/app/config';
import { CodeBlock } from '~/components/CodeBlock';
import { ExternalLink } from '~/components/ExternalLink';
import { InternalLink } from '~/components/InternalLink';
import { PageNavigation } from '~/components/PageNavigation';
import { PageSubtitle } from '~/components/PageSubtitle';
import { PageTitle } from '~/components/PageTitle';
import { Txt } from '~/components/Txt';
import { readCodeFile } from '~/lib/code';
import { getRouteMetadata } from '~/lib/utils';
import { RowActionsCellExample } from './RowActionsCellExample';
import { RowActionsCellExample, RowActionsCellExampleConstrainWidth } from './RowActionsCellExamples';

const PATH: Route = '/examples/row-actions-cell';

export const metadata = getRouteMetadata(PATH);

export default async function RowActionsCellExamplePage() {
const code = await readCodeFile<string>(`${PATH}/RowActionsCellExample.tsx`);
const code = await readCodeFile<Record<'default' | 'constrain-width', string>>(`${PATH}/RowActionsCellExamples.tsx`);

return (
<>
Expand All @@ -28,7 +30,7 @@ export default async function RowActionsCellExamplePage() {
</Txt>
<RowActionsCellExample />
<Txt>Here is the code:</Txt>
<CodeBlock code={code} />
<CodeBlock code={code['default']} />
<Txt info title="Heads up">
If you need to combine row actions with{' '}
<InternalLink to="/examples/handling-row-clicks">clickable rows</InternalLink>,{' '}
Expand All @@ -46,6 +48,16 @@ export default async function RowActionsCellExamplePage() {
See <InternalLink to="/examples/links-or-buttons-inside-clickable-rows-or-cells">this example</InternalLink> for
more information.
</Txt>
<PageSubtitle value="Constraining the actions column width" />
<Txt>
If you want to constrain the actions column to be no wider than its content, you can set its <Code>width</Code>{' '}
to <Code>&apos;0%&apos;</Code> and, if you have more than one action icon, make sure the actions are wrapped in
a <ExternalLink to={`${MANTINE_LINK}/core/group/`}>Mantine Group</ExternalLink> component with{' '}
<Code>wrap=&apos;nowrap&apos;</Code>:
</Txt>
<RowActionsCellExampleConstrainWidth />
<Txt>Here is the code:</Txt>
<CodeBlock code={code['constrain-width']} />
<Txt>Head over to the next example to discover more features.</Txt>
<PageNavigation of={PATH} />
</>
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
"devDependencies": {
"@docsearch/react": "^3.5.2",
"@ducanh2912/next-pwa": "^10.2.2",
"@ducanh2912/next-pwa": "^10.2.3",
"@faker-js/faker": "^8.4.0",
"@formkit/auto-animate": "^0.8.1",
"@mantine/code-highlight": "^7.5.0",
Expand All @@ -82,13 +82,13 @@
"@mantine/modals": "^7.5.0",
"@mantine/notifications": "^7.5.0",
"@tabler/icons-react": "^2.46.0",
"@tanstack/react-query": "^5.17.19",
"@tanstack/react-query": "^5.18.0",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.9",
"@types/node": "^20.11.13",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"clsx": "^2.1.0",
"cssnano": "^6.0.3",
"dayjs": "^1.11.10",
Expand Down
134 changes: 67 additions & 67 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,10 @@
"@docsearch/css" "3.5.2"
algoliasearch "^4.19.1"

"@ducanh2912/next-pwa@^10.2.2":
version "10.2.2"
resolved "https://registry.yarnpkg.com/@ducanh2912/next-pwa/-/next-pwa-10.2.2.tgz#b72880bfaf791b4135a72803861cfc83bebbd256"
integrity sha512-4WCMTI8aGQlLbxBVmXlGQuTTvSkAUdxvZl6o18znW1jcOd64K7SmJcMbh+MdJDw6s5eqG/uAKfbmA0JMC/c9iQ==
"@ducanh2912/next-pwa@^10.2.3":
version "10.2.3"
resolved "https://registry.yarnpkg.com/@ducanh2912/next-pwa/-/next-pwa-10.2.3.tgz#138ff99e3b13b66f7f0a117c6d1cb3d11ab962aa"
integrity sha512-Bdn7zCRFKhSCyrlqKzjFi7Y3/1F+z3PPHsPOhqsMo9H0cVybaDjlLxr6E9SiTy9K0fx2//8QPuEHGZof/UmVoA==
dependencies:
clean-webpack-plugin "4.0.0"
fast-glob "3.3.2"
Expand Down Expand Up @@ -1772,17 +1772,17 @@
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-2.46.0.tgz#e629df8901b799372914c694000cc2ea3d45bb6b"
integrity sha512-Q5G8Pj5IO+Uhc6pszpu5/hGYY018JwEzzvmuqr+gKJtfIvAHA3umpwUilMRLEy89p+WCP+YsDhicMhfBCCv1qA==

"@tanstack/query-core@5.17.19":
version "5.17.19"
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.17.19.tgz#212515ccc7a6b913afee6b71ce3e7df2c4d85f7d"
integrity sha512-Lzw8FUtnLCc9Jwz0sw9xOjZB+/mCCmJev38v2wHMUl/ioXNIhnNWeMxu0NKUjIhAd62IRB3eAtvxAGDJ55UkyA==
"@tanstack/query-core@5.18.0":
version "5.18.0"
resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.18.0.tgz#445a0cbf94b49d57132255c74570cfb63cf444c2"
integrity sha512-8c6nxeAnGHxIDZIyDmHdmgFt4D+LprAQaJmjsnM4szcIjsWOyFlzxdqQUuQ/XuQRvUgqYaqlJTtDADlSS7pTPQ==

"@tanstack/react-query@^5.17.19":
version "5.17.19"
resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.17.19.tgz#d6fc243faa469bb84952dd810faea47dabe389fc"
integrity sha512-qaQENB6/03Gj3dFZGvdmUoqeUGlGm7P1p0RmaR04Bf1Ib1T9lLGimcC9T3oCFbrx0b2ZF21ngjFZNjj9uPJMcg==
"@tanstack/react-query@^5.18.0":
version "5.18.0"
resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.18.0.tgz#da948737c904e7796df2aab2e52a92bdd755ffb1"
integrity sha512-7FKxNfxxKEL7n3ADpwp81Fy4FX85hNkYVzQQVQsF0JAPl93c3d1gmNZMIbEtOqgYfom1/ontGh3FiZGYj3xyWA==
dependencies:
"@tanstack/query-core" "5.17.19"
"@tanstack/query-core" "5.18.0"

"@trysound/[email protected]":
version "0.2.0"
Expand Down Expand Up @@ -1853,10 +1853,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.9.tgz#c7164e0f8d3f12dfae336af0b1f7fdec8c6b204f"
integrity sha512-8e2HYcg7ohnTUbHk8focoklEQYvemQmu9M/f43DZVx43kHn0tE3BY/6gSDxS7k0SprtS0NHvj+L80cGLnoOUcQ==

"@types/node@^20.11.9":
version "20.11.9"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.9.tgz#959d436f20ce2ee3df897c3eaa0617c98fa70efb"
integrity sha512-CQXNuMoS/VcoAMISe5pm4JnEd1Br5jildbQEToEMQvutmv+EaQr90ry9raiudgpyDuqFiV9e4rnjSfLNq12M5w==
"@types/node@^20.11.13":
version "20.11.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.13.tgz#188263ee2c8d590e181d3f5bfa7e485a932957cb"
integrity sha512-5G4zQwdiQBSWYTDAH1ctw2eidqdhMJaNsiIDKHFr55ihz5Trl2qqR8fdrT732yPBho5gkNxXm67OxWFBqX9aPg==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -1912,16 +1912,16 @@
resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-2.0.3.tgz#a136f83b0758698df454e328759dbd3d44555311"
integrity sha512-NfQ4gyz38SL8sDNrSixxU2Os1a5xcdFxipAFxYEuLUlvU2uDwS4NUpsImcf1//SlWItCVMMLiylsxbmNMToV/g==

"@typescript-eslint/eslint-plugin@^6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.19.1.tgz#bb0676af940bc23bf299ca58dbdc6589c2548c2e"
integrity sha512-roQScUGFruWod9CEyoV5KlCYrubC/fvG8/1zXuT0WTcxX87GnMMmnksMwSg99lo1xiKrBzw2icsJPMAw1OtKxg==
"@typescript-eslint/eslint-plugin@^6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.20.0.tgz#9cf31546d2d5e884602626d89b0e0d2168ac25ed"
integrity sha512-fTwGQUnjhoYHeSF6m5pWNkzmDDdsKELYrOBxhjMrofPqCkoC2k3B2wvGHFxa1CTIqkEn88nlW1HVMztjo2K8Hg==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
"@typescript-eslint/scope-manager" "6.19.1"
"@typescript-eslint/type-utils" "6.19.1"
"@typescript-eslint/utils" "6.19.1"
"@typescript-eslint/visitor-keys" "6.19.1"
"@typescript-eslint/scope-manager" "6.20.0"
"@typescript-eslint/type-utils" "6.20.0"
"@typescript-eslint/utils" "6.20.0"
"@typescript-eslint/visitor-keys" "6.20.0"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
Expand All @@ -1940,24 +1940,24 @@
"@typescript-eslint/visitor-keys" "6.3.0"
debug "^4.3.4"

"@typescript-eslint/parser@^6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.19.1.tgz#68a87bb21afaf0b1689e9cdce0e6e75bc91ada78"
integrity sha512-WEfX22ziAh6pRE9jnbkkLGp/4RhTpffr2ZK5bJ18M8mIfA8A+k97U9ZyaXCEJRlmMHh7R9MJZWXp/r73DzINVQ==
"@typescript-eslint/parser@^6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.20.0.tgz#17e314177304bdf498527e3c4b112e41287b7416"
integrity sha512-bYerPDF/H5v6V76MdMYhjwmwgMA+jlPVqjSDq2cRqMi8bP5sR3Z+RLOiOMad3nsnmDVmn2gAFCyNgh/dIrfP/w==
dependencies:
"@typescript-eslint/scope-manager" "6.19.1"
"@typescript-eslint/types" "6.19.1"
"@typescript-eslint/typescript-estree" "6.19.1"
"@typescript-eslint/visitor-keys" "6.19.1"
"@typescript-eslint/scope-manager" "6.20.0"
"@typescript-eslint/types" "6.20.0"
"@typescript-eslint/typescript-estree" "6.20.0"
"@typescript-eslint/visitor-keys" "6.20.0"
debug "^4.3.4"

"@typescript-eslint/scope-manager@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.19.1.tgz#2f527ee30703a6169a52b31d42a1103d80acd51b"
integrity sha512-4CdXYjKf6/6aKNMSly/BP4iCSOpvMmqtDzRtqFyyAae3z5kkqEjKndR5vDHL8rSuMIIWP8u4Mw4VxLyxZW6D5w==
"@typescript-eslint/scope-manager@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz#8a926e60f6c47feb5bab878246dc2ae465730151"
integrity sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==
dependencies:
"@typescript-eslint/types" "6.19.1"
"@typescript-eslint/visitor-keys" "6.19.1"
"@typescript-eslint/types" "6.20.0"
"@typescript-eslint/visitor-keys" "6.20.0"

"@typescript-eslint/[email protected]":
version "6.3.0"
Expand All @@ -1967,33 +1967,33 @@
"@typescript-eslint/types" "6.3.0"
"@typescript-eslint/visitor-keys" "6.3.0"

"@typescript-eslint/type-utils@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.19.1.tgz#6a130e3afe605a4898e043fa9f72e96309b54935"
integrity sha512-0vdyld3ecfxJuddDjACUvlAeYNrHP/pDeQk2pWBR2ESeEzQhg52DF53AbI9QCBkYE23lgkhLCZNkHn2hEXXYIg==
"@typescript-eslint/type-utils@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.20.0.tgz#d395475cd0f3610dd80c7d8716fa0db767da3831"
integrity sha512-qnSobiJQb1F5JjN0YDRPHruQTrX7ICsmltXhkV536mp4idGAYrIyr47zF/JmkJtEcAVnIz4gUYJ7gOZa6SmN4g==
dependencies:
"@typescript-eslint/typescript-estree" "6.19.1"
"@typescript-eslint/utils" "6.19.1"
"@typescript-eslint/typescript-estree" "6.20.0"
"@typescript-eslint/utils" "6.20.0"
debug "^4.3.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/types@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.19.1.tgz#2d4c9d492a63ede15e7ba7d129bdf7714b77f771"
integrity sha512-6+bk6FEtBhvfYvpHsDgAL3uo4BfvnTnoge5LrrCj2eJN8g3IJdLTD4B/jK3Q6vo4Ql/Hoip9I8aB6fF+6RfDqg==
"@typescript-eslint/types@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.20.0.tgz#5ccd74c29011ae7714ae6973e4ec0c634708b448"
integrity sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==

"@typescript-eslint/[email protected]":
version "6.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.3.0.tgz#84517f1427923e714b8418981e493b6635ab4c9d"
integrity sha512-K6TZOvfVyc7MO9j60MkRNWyFSf86IbOatTKGrpTQnzarDZPYPVy0oe3myTMq7VjhfsUAbNUW8I5s+2lZvtx1gg==

"@typescript-eslint/typescript-estree@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.19.1.tgz#796d88d88882f12e85bb33d6d82d39e1aea54ed1"
integrity sha512-aFdAxuhzBFRWhy+H20nYu19+Km+gFfwNO4TEqyszkMcgBDYQjmPJ61erHxuT2ESJXhlhrO7I5EFIlZ+qGR8oVA==
"@typescript-eslint/typescript-estree@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz#5b2d0975949e6bdd8d45ee1471461ef5fadc5542"
integrity sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==
dependencies:
"@typescript-eslint/types" "6.19.1"
"@typescript-eslint/visitor-keys" "6.19.1"
"@typescript-eslint/types" "6.20.0"
"@typescript-eslint/visitor-keys" "6.20.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
Expand All @@ -2014,25 +2014,25 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/utils@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.19.1.tgz#df93497f9cfddde2bcc2a591da80536e68acd151"
integrity sha512-JvjfEZuP5WoMqwh9SPAPDSHSg9FBHHGhjPugSRxu5jMfjvBpq5/sGTD+9M9aQ5sh6iJ8AY/Kk/oUYVEMAPwi7w==
"@typescript-eslint/utils@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.20.0.tgz#0e52afcfaa51af5656490ba4b7437cc3aa28633d"
integrity sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.19.1"
"@typescript-eslint/types" "6.19.1"
"@typescript-eslint/typescript-estree" "6.19.1"
"@typescript-eslint/scope-manager" "6.20.0"
"@typescript-eslint/types" "6.20.0"
"@typescript-eslint/typescript-estree" "6.20.0"
semver "^7.5.4"

"@typescript-eslint/visitor-keys@6.19.1":
version "6.19.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.19.1.tgz#2164073ed4fc34a5ff3b5e25bb5a442100454c4c"
integrity sha512-gkdtIO+xSO/SmI0W68DBg4u1KElmIUo3vXzgHyGPs6cxgB0sa3TlptRAAE0hUY1hM6FcDKEv7aIwiTGm76cXfQ==
"@typescript-eslint/visitor-keys@6.20.0":
version "6.20.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz#f7ada27f2803de89df0edd9fd7be22c05ce6a498"
integrity sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==
dependencies:
"@typescript-eslint/types" "6.19.1"
"@typescript-eslint/types" "6.20.0"
eslint-visitor-keys "^3.4.1"

"@typescript-eslint/[email protected]":
Expand Down

0 comments on commit 6165045

Please sign in to comment.