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

website: Update variables documentation & demos #1334

Merged
merged 22 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5909d35
Initial push.
FlyersPh9 Jun 7, 2023
578944f
Remove `<RelatedComponents>`.
FlyersPh9 Jun 7, 2023
63b4435
Lower each `<h*>` 1 level.
FlyersPh9 Jun 7, 2023
fea0170
Update duration demo.
FlyersPh9 Jun 7, 2023
cbb0104
Re-add `1rem` = `m` and mention "root font size".
FlyersPh9 Jun 7, 2023
09a1409
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 8, 2023
091a499
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 8, 2023
485b59e
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 8, 2023
62423df
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 8, 2023
f74d77c
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 8, 2023
417a902
Intro paragraph change.
FlyersPh9 Jun 8, 2023
b1ca68b
Add component height variable names.
FlyersPh9 Jun 14, 2023
2ee3f04
Add color & opacity pairing section with accessibility warning.
FlyersPh9 Jun 14, 2023
1d97401
Duration demo now requires a click to activate.
FlyersPh9 Jun 14, 2023
ad266d0
Duration demo cleanup
FlyersPh9 Jun 14, 2023
8adfd39
Merge branch 'dev' into jon/documentation-site-variables
FlyersPh9 Jun 15, 2023
46198dd
Replace with
FlyersPh9 Jun 15, 2023
8dbb671
Update apps/website/src/pages/docs/variables.mdx
FlyersPh9 Jun 15, 2023
6022c9d
Update duration demo with Mayank's suggestion
FlyersPh9 Jun 15, 2023
86682a5
Trying to be more clear about the range within opacity and duration.
FlyersPh9 Jun 15, 2023
83222ef
Sort sections alphabetically
FlyersPh9 Jun 15, 2023
84cec85
Merge branch 'dev' into jon/documentation-site-variables
gretanausedaite Jun 20, 2023
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
2 changes: 1 addition & 1 deletion apps/website/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function rehypeToc() {

// ideally we would check if the frontmatter has a toc: false, but that is not available
// so we will hardcode the files we don't want a toc for
if (['index.mdx', 'variables.mdx'].includes(file.history[0].split('/').pop()!)) {
if (['index.mdx'].includes(file.history[0].split('/').pop()!)) {
showTOC = false;
}

Expand Down
48 changes: 48 additions & 0 deletions apps/website/src/components/variables/DurationDemo.astro
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 demo is a bit intense. Suggestions for an alternative demo?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a gentle fade?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realized my animation was incorrect. It was applying the duration speed to expand AND collapse. I've added animation-direction: alternate; so now the animation is half of what it was. Still a bit intense, but better than before.

I will look into other options next time I work on this PR, with the time I have today this is the best I could do.

Copy link
Contributor

Choose a reason for hiding this comment

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

A non-repeating animation that can be triggered by the user would be the best option. For inspiration, see https://open-props.style/#animations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to require a user's click to trigger animation.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm it's not working for me. did you forget to add a script?

Screen.Recording.2023-06-15.at.1.44.50.PM.mov

Copy link
Contributor

Choose a reason for hiding this comment

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

you can fix it using this code:

DurationDemo.astro
---
import Wrapper from './_wrapper.astro';
const durations = ['0', '1', '2', '3'];
---

<Wrapper class='wrapper'>
  {
    durations.map((duration) => (
      <duration-item duration={`--iui-duration-${duration}`}>
        <button>{duration}</button>
      </duration-item>
    ))
  }
</Wrapper>

<script>
  customElements.define(
    'duration-item',
    class extends HTMLElement {
      connectedCallback() {
        const duration = getComputedStyle(this).getPropertyValue(this.getAttribute('duration'));
        const durationMs = Math.max(0.001, parseFloat(duration) * 1000);
        const button = this.querySelector('button');

        button.addEventListener('click', () => {
          button.animate([{ opacity: 0 }], { duration: durationMs });
        });
      }
    }
  );
</script>

<style>
  duration-item button {
    border: none;
    padding: var(--space-3);
    width: var(--space-8);
    height: var(--space-8);
    border-radius: var(--space-1);
    box-shadow: 0 0 4px hsl(0 0% 0% / 20%);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--iui-color-background);
    color: var(--iui-color-foreground-2);
    cursor: pointer;
  }
</style>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just tested it in Brave & Safari, those both seems to be working.
duration-demo

Firefox however is not working. 😫

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you, the suggested code works in all browsers!

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
import Wrapper from './_wrapper.astro';
const durations = ['0', '1', '2', '3'];
---

<Wrapper class='wrapper'>
{
durations.map((duration) => (
<duration-item duration={`--iui-duration-${duration}`}>
<button>{duration}</button>
</duration-item>
))
}
</Wrapper>

<script>
customElements.define(
'duration-item',
class extends HTMLElement {
connectedCallback() {
const duration = getComputedStyle(this).getPropertyValue(this.getAttribute('duration'));
const durationMs = Math.max(0.001, parseFloat(duration) * 1000);
const button = this.querySelector('button');

button.addEventListener('click', () => {
button.animate([{ opacity: 0 }], { duration: durationMs });
});
}
}
);
</script>

<style>
duration-item button {
border: none;
padding: var(--space-3);
width: var(--space-8);
height: var(--space-8);
border-radius: var(--space-1);
box-shadow: 0 0 4px hsl(0 0% 0% / 20%);
display: flex;
align-items: center;
justify-content: center;
background-color: var(--iui-color-background);
color: var(--iui-color-foreground-2);
cursor: pointer;
}
</style>
29 changes: 29 additions & 0 deletions apps/website/src/components/variables/SizesInputDemo.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
import Wrapper from './_wrapper.astro';
import Item from './_item.astro';
---

<Wrapper class='wrapper'>
<Item class='item'>small</Item>
<Item class='item'>medium</Item>
FlyersPh9 marked this conversation as resolved.
Show resolved Hide resolved
<Item class='item'>large</Item>
</Wrapper>

<style lang='scss'>
.wrapper {
align-items: center;
}

.item {
border-radius: var(--iui-border-radius-1);
height: var(--iui-component-height);

&:first-child {
height: var(--iui-component-height-small);
}

&:last-child {
height: var(--iui-component-height-large);
}
}
</style>
Loading