Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-4749: Code loading skeleton #2663

Merged
merged 126 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
ef34493
wip
shaneeza Jan 7, 2025
b71de4e
wip - updating panel styles
shaneeza Jan 7, 2025
029a90e
updated panel styles
shaneeza Jan 7, 2025
6ef16ba
trying to combine styles
shaneeza Jan 7, 2025
794fe08
move styles to styles file
shaneeza Jan 9, 2025
2e19572
updating panel types
shaneeza Jan 9, 2025
e21b374
added context
shaneeza Jan 9, 2025
07426d1
ts docs
shaneeza Jan 9, 2025
9994560
update copy button styles in panel
shaneeza Jan 9, 2025
3af02dc
organize code style file
shaneeza Jan 9, 2025
ffb7c2f
update types
shaneeza Jan 9, 2025
db94d82
remove unused type
shaneeza Jan 9, 2025
68f6b57
wip code tests
shaneeza Jan 10, 2025
02ede13
add language prop to context
shaneeza Jan 10, 2025
56c69e5
more tests updates
shaneeza Jan 10, 2025
79f9394
remove some tests
shaneeza Jan 10, 2025
ac0cadf
delete windowChrome and CustomSelectMenuButton
shaneeza Jan 10, 2025
893f021
fix onChangeError
shaneeza Jan 10, 2025
2fd12a6
remove comment
shaneeza Jan 10, 2025
a1d68a6
check if language is in option
shaneeza Jan 10, 2025
2a35411
add copyButtonAppearance prop
shaneeza Jan 13, 2025
f7164ca
add clipboard check
shaneeza Jan 13, 2025
05f3f67
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 13, 2025
9e108d7
remove copyable prop
shaneeza Jan 13, 2025
d1ecc7b
copy button styles
shaneeza Jan 14, 2025
b1f40b1
wip adding isLoadingProp
shaneeza Jan 15, 2025
bbf2a2d
add isLoading to context
shaneeza Jan 15, 2025
5b4276f
disabled copy icon styles
shaneeza Jan 15, 2025
da970a8
isLoading tests
shaneeza Jan 16, 2025
696bcd7
added back props i initially deleted
shaneeza Jan 16, 2025
597eba3
remove props from context
shaneeza Jan 16, 2025
bf064a6
update tsdocs
shaneeza Jan 17, 2025
2b77d46
rename func and update tsdocs
shaneeza Jan 17, 2025
8a6c5e3
add todo tests
shaneeza Jan 17, 2025
e41fac7
adding more tests
shaneeza Jan 21, 2025
1e4a020
remove unused tests
shaneeza Jan 21, 2025
84c7542
merge conflict
shaneeza Jan 21, 2025
d561827
merge conflict
shaneeza Jan 22, 2025
b461adc
fix languageswitcher example
shaneeza Jan 22, 2025
85037f5
fix errors
shaneeza Jan 22, 2025
90ab34c
fix errors
shaneeza Jan 22, 2025
f35d883
remove copyable false
shaneeza Jan 22, 2025
7b04bc6
add error test
shaneeza Jan 22, 2025
c2fc2b0
update tests and tsdocs
shaneeza Jan 22, 2025
fd23e6a
clean up
shaneeza Jan 22, 2025
f45e3a7
testids
shaneeza Jan 22, 2025
eadcc1b
merge conflicts
shaneeza Jan 22, 2025
485b0fc
merge conflict
shaneeza Jan 22, 2025
a5d6008
dont skip test
shaneeza Jan 22, 2025
36972e5
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 22, 2025
f7611b1
Merge branch 'LG-4760/code-copy-button' of github.com:mongodb/leafygr…
shaneeza Jan 22, 2025
a2a44f5
update padding
shaneeza Jan 22, 2025
571a0c7
updating generate stories
shaneeza Jan 22, 2025
339e8be
fix story error
shaneeza Jan 22, 2025
3d284ed
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 22, 2025
3de4d8e
merge conflict
shaneeza Jan 23, 2025
a02a756
fix build error
shaneeza Jan 23, 2025
e88a6f9
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-4748-…
shaneeza Jan 23, 2025
64aefdc
clean up
shaneeza Jan 23, 2025
c45e257
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-4748-…
shaneeza Jan 23, 2025
6c42aa6
readme updates
shaneeza Jan 23, 2025
7e9898e
forgot to save
shaneeza Jan 23, 2025
500ab13
fix language type
shaneeza Jan 23, 2025
5f5ecfb
lint
shaneeza Jan 23, 2025
8a8d39c
more tests
shaneeza Jan 23, 2025
394ae5e
remove fireevent
shaneeza Jan 23, 2025
cd99321
fix dep errors
shaneeza Jan 23, 2025
db02b0e
update lock file
shaneeza Jan 23, 2025
4255681
merge conflict
shaneeza Jan 23, 2025
6ca77cb
add generated stories
shaneeza Jan 24, 2025
e1030de
lint
shaneeza Jan 24, 2025
149ff69
title fix
shaneeza Jan 24, 2025
9a45d18
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 24, 2025
62f8b52
remove unused code and add new styles for button
shaneeza Jan 24, 2025
f43f0fb
updates
shaneeza Jan 26, 2025
a5123a1
lint
shaneeza Jan 26, 2025
10b22b5
forgot to save
shaneeza Jan 26, 2025
9f0da7e
merge conflict
shaneeza Jan 26, 2025
b4cd95f
loading story
shaneeza Jan 26, 2025
b10b6f6
lint
shaneeza Jan 26, 2025
4975572
some cleanup
shaneeza Jan 26, 2025
9a8bada
update test to use context
shaneeza Jan 26, 2025
8184e9a
fix spelling
shaneeza Jan 26, 2025
a3dd9c4
Merge branch 'LG-4760/code-copy-button' of github.com:mongodb/leafygr…
shaneeza Jan 26, 2025
3ac48a6
remove comments
shaneeza Jan 26, 2025
bd339cf
lint
shaneeza Jan 27, 2025
a292195
remove comment
shaneeza Jan 27, 2025
ec6b9d4
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 27, 2025
b4dca10
update test
shaneeza Jan 27, 2025
d1f5264
merge conflict
shaneeza Jan 27, 2025
2ac9395
feedback
shaneeza Jan 27, 2025
56afc5a
changeset
shaneeza Jan 27, 2025
facac67
typos
shaneeza Jan 27, 2025
a39be45
rephrase
shaneeza Jan 27, 2025
705a6c2
update test
shaneeza Jan 27, 2025
b9da5f9
Merge branch 'LG-4748-code-panel' of github.com:mongodb/leafygreen-ui…
shaneeza Jan 27, 2025
7fcbe7f
readme
shaneeza Jan 27, 2025
e051c3c
update docs
shaneeza Jan 27, 2025
55f6527
clean up
shaneeza Jan 27, 2025
4e322db
lib changeset
shaneeza Jan 27, 2025
e05cfda
test order
shaneeza Jan 27, 2025
cf28e29
add ticket
shaneeza Jan 28, 2025
dd51f84
update docs
shaneeza Jan 28, 2025
1168eb3
fix story props
shaneeza Jan 28, 2025
33538df
sandy feedback
shaneeza Jan 28, 2025
1d1deb3
fix build error
shaneeza Jan 28, 2025
5f1c58c
merge conflict
shaneeza Jan 28, 2025
49625f4
merge conflict
shaneeza Jan 29, 2025
813d6f4
build and story updates
shaneeza Jan 29, 2025
48a968a
lock
shaneeza Jan 29, 2025
daff28f
update genereated stories
shaneeza Jan 29, 2025
b8de180
showPanel and story updates
shaneeza Jan 29, 2025
b8ec8e5
add showCopyButtonWithoutPanel const
shaneeza Jan 29, 2025
0e23069
remove extra div
shaneeza Jan 29, 2025
0cce4b0
discriminated union for copyButtonAppearnce and panel
shaneeza Jan 29, 2025
e0d7288
use getMobileMediaQuery in select
shaneeza Jan 29, 2025
40839f8
changeset
shaneeza Jan 29, 2025
7dd19e7
doc feedback
shaneeza Jan 30, 2025
3beac53
fix tooltip issue and be more specific with svg styles
shaneeza Jan 30, 2025
47b0a0d
merge conflict
shaneeza Jan 30, 2025
a7ec53e
add isLoading check
shaneeza Jan 30, 2025
b5af1af
merge conflict
shaneeza Jan 30, 2025
164f544
fix disabled copy button styles
shaneeza Jan 30, 2025
6923499
docs
shaneeza Jan 30, 2025
acb8e86
remove dup copy button
shaneeza Jan 30, 2025
05b9e4d
fix readme
shaneeza Jan 31, 2025
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
46 changes: 31 additions & 15 deletions .changeset/chatty-ears-exercise.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
'@leafygreen-ui/code': major
---

## What's new?

### `panel`
Expand Down Expand Up @@ -49,6 +50,20 @@ e.g.
</Code>
```

### `isLoading`
Adds a new prop, `isLoading`. This prop determines whether or not the loading skeleton will be rendered in place of the code block. If `true`, the language switcher and copy button will be disabled in the top panel.

e.g.

```js
<Code
language="javascript"
isLoading
>
{snippet}
</Code>
```


### `chromeTitle`

Expand All @@ -64,15 +79,17 @@ e.g.
**After**:
```js
<Code
panel={
<Panel
title="Title"
/>
}
panel={<Panel title="Title" />}
>
{snippet}
</Code>
```

## What's changed?

The `className` prop is no longer applied to the `<pre>` tag. Instead it is applied to the parent `<div>` wrapper.


## Deprecated

The following props have been marked as `deprecated`:
Expand All @@ -88,16 +105,15 @@ Moving forward these props should be passed to the new sub-component, `<Panel />
**Before**:
```js
<Code
language={}
showLineNumbers={}
language="javascript"
showLineNumbers
onCopy={() => {}}
darkMode={}
customActionButtons={}
showCustomActionButtons={}
chromeTitle={}
languageOptions={}
onChange={}
copyable={}
darkMode={true}
onChange={() => {}}
languageOptions={[]}
showCustomActionButtons
customActionButtons={[]}
chromeTitle='Title'
>
{snippet}
</Code>
Expand All @@ -107,7 +123,7 @@ Moving forward these props should be passed to the new sub-component, `<Panel />
```js
<Code
language="javascript"
showLineNumbers={true}
showLineNumbers
onCopy={() => {}}
darkMode={true}
// NEW PANEL PROP
Expand Down
39 changes: 20 additions & 19 deletions packages/code/README.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have some text left over from conflict in this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was hard to fix, so I copied it from the integration branch and added back the isLoading prop

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@leafygreen-ui/lib": "workspace:^",
"@leafygreen-ui/palette": "workspace:^",
"@leafygreen-ui/select": "workspace:^",
"@leafygreen-ui/skeleton-loader": "workspace:^",
"@leafygreen-ui/tokens": "workspace:^",
"@leafygreen-ui/tooltip": "workspace:^",
"@leafygreen-ui/typography": "workspace:^",
Expand Down
35 changes: 34 additions & 1 deletion packages/code/src/Code.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type StoryType,
} from '@lg-tools/storybook-utils';

import { css } from '@leafygreen-ui/emotion';
import Icon from '@leafygreen-ui/icon';
import IconButton from '@leafygreen-ui/icon-button';
import LeafygreenProvider from '@leafygreen-ui/leafygreen-provider';
Expand Down Expand Up @@ -83,7 +84,7 @@ const meta: StoryMetaType<typeof Code> = {
],
},
generate: {
storyNames: ['WithPanel', 'WithoutPanel'],
storyNames: ['WithPanel', 'WithoutPanel', 'Loading'],
},
},
args: {
Expand All @@ -94,6 +95,7 @@ const meta: StoryMetaType<typeof Code> = {
chromeTitle: '',
},
argTypes: {
isLoading: { control: 'boolean' },
copyable: { control: 'boolean' },
expandable: { control: 'boolean' },
showLineNumbers: { control: 'boolean' },
Expand Down Expand Up @@ -132,6 +134,9 @@ export const LiveExample: StoryType<typeof Code, FontSizeProps> = ({
<Code
{...(args as CodeProps)}
highlightLines={highlightLines ? [6, [10, 15]] : undefined}
className={css`
width: 100%;
`}
>
{jsSnippet}
</Code>
Expand Down Expand Up @@ -318,3 +323,31 @@ WithoutPanel.parameters = {
],
},
};

export const Loading = () => {};
Loading.parameters = {
controls: {
exclude: /.*/g,
},
generate: {
combineArgs: {
darkMode: [false, true],
expandable: [true, false],
panel: [
undefined,
<Panel
title="Title"
showCustomActionButtons
customActionButtons={customActionButtons}
languageOptions={languageOptions}
onChange={() => {}}
key={7}
/>,
],
},
args: {
language: languageOptions[0].displayName,
isLoading: true,
},
},
};
Loading