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

[ColorSystem][MessageIndicator] Improve contrast and use color system #2428

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

chloerice
Copy link
Member

@chloerice chloerice commented Nov 13, 2019

WHY are these changes introduced?

To improve the contrast of MessageIndicator shown when message is set on TopBar.UserMenu. Thanks for the design @AdamWhitcroft 🎉

cc @mirualves for UI Kit

WHAT is this pull request doing?

Added a border for the message indicator colored with the --p-surface-background CSS variable. The indicator's color now uses the --p-highlight-icon CSS variable.

Before After
Screen Shot 2019-11-14 at 4 07 24 PM Screen Shot 2019-11-13 at 1 48 35 PM
Screen Shot 2019-11-14 at 4 24 09 PM Screen Shot 2019-11-14 at 4 23 20 PM
Screen Shot 2019-11-14 at 4 23 59 PM Screen Shot 2019-11-14 at 4 23 31 PM
Screen Shot 2019-11-14 at 4 34 33 PM Screen Shot 2019-11-14 at 4 34 15 PM

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

Copy-paste this code in playground/Playground.tsx:
import React, {useCallback, useState} from 'react';
import {ArrowLeftMinor} from '@shopify/polaris-icons';
import {Page, Card, ActionList, TopBar, Frame, AppProvider} from '../src';

export function Playground() {
  const [isUserMenuOpen, setIsUserMenuOpen] = useState(false);
  const [isSearchActive, setIsSearchActive] = useState(false);
  const [searchValue, setSearchValue] = useState('');

  const toggleIsUserMenuOpen = useCallback(
    () => setIsUserMenuOpen((isUserMenuOpen) => !isUserMenuOpen),
    [],
  );

  const handleSearchResultsDismiss = useCallback(() => {
    setIsSearchActive(false);
    setSearchValue('');
  }, []);

  const handleSearchChange = useCallback((value) => {
    setSearchValue(value);
    setIsSearchActive(value.length > 0);
  }, []);

  const handleNavigationToggle = useCallback(() => {
    console.log('toggle navigation visibility');
  }, []);

  const theme = {
    colors: {},
    logo: {
      width: 124,
      topBarSource:
        'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999',
      url: 'http://jadedpixel.com',
      accessibilityLabel: 'Jaded Pixel',
    },
  };

  const userMenuMessage = {
    title: 'New message',
    description: 'Description',
    action: {
      content: 'Message action',
      onClick: () => {
        console.log('User menu message clicked');
      },
    },
    link: {to: '/', content: 'User menu message link'},
  };

  const userMenuMarkup = (
    <TopBar.UserMenu
      actions={[
        {
          items: [{content: 'Back to Shopify', icon: ArrowLeftMinor}],
        },
        {
          items: [{content: 'Community forums'}],
        },
      ]}
      name="Dharma"
      detail="Jaded Pixel"
      initials="D"
      message={userMenuMessage}
      open={isUserMenuOpen}
      onToggle={toggleIsUserMenuOpen}
    />
  );

  const searchResultsMarkup = (
    <Card>
      <ActionList
        items={[
          {content: 'Shopify help center'},
          {content: 'Community forums'},
        ]}
      />
    </Card>
  );

  const searchFieldMarkup = (
    <TopBar.SearchField
      onChange={handleSearchChange}
      value={searchValue}
      placeholder="Search"
    />
  );

  const topBarMarkup = (
    <TopBar
      showNavigationToggle
      userMenu={userMenuMarkup}
      searchResultsVisible={isSearchActive}
      searchField={searchFieldMarkup}
      searchResults={searchResultsMarkup}
      onSearchResultsDismiss={handleSearchResultsDismiss}
      onNavigationToggle={handleNavigationToggle}
    />
  );

  return (
    <div style={{height: '250px'}}>
      <AppProvider
        i18n={{
          Polaris: {
            Avatar: {
              label: 'Avatar',
              labelWithInitials: 'Avatar with initials {initials}',
            },
            Frame: {skipToContent: 'Skip to content'},
            TopBar: {
              toggleMenuLabel: 'Toggle menu',
              SearchField: {
                clearButtonLabel: 'Clear',
                search: 'Search',
              },
            },
          },
        }}
      >
        <Frame topBar={topBarMarkup} />
      </AppProvider>
    </div>
  );
}

🎩 checklist

@chloerice chloerice changed the title [MessageIndicator] Convert to use color system, improve contrast [WIP][MessageIndicator] Convert to use color system, improve contrast Nov 13, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2019

💦 Potential splash zone of changes introduced to src/**/*.tsx in this pull request:

Files modified2
Files potentially affected3

Details

All files potentially affected (total: 3)
📄 UNRELEASED.md (total: 0)

Files potentially affected (total: 0)

🎨 src/components/MessageIndicator/MessageIndicator.scss (total: 3)

Files potentially affected (total: 3)


This comment automatically updates as changes are made to this pull request.
Feedback, troubleshooting: open an issue or reach out on Slack in #polaris-tooling.

@chloerice chloerice changed the title [WIP][MessageIndicator] Convert to use color system, improve contrast [WIP][ColorSystem] Convert MessageIndicator to use color system, improve contrast Nov 13, 2019
@chloerice chloerice force-pushed the message-indicator-color-system branch from 4c1e3c3 to bdf9550 Compare November 14, 2019 21:21
@chloerice chloerice changed the title [WIP][ColorSystem] Convert MessageIndicator to use color system, improve contrast [ColorSystem][MessageIndicator] Improve contrast and use color system Nov 14, 2019
@chloerice chloerice force-pushed the message-indicator-color-system branch 2 times, most recently from 38874a7 to 3f7fada Compare November 14, 2019 21:56
Copy link
Contributor

@tmlayton tmlayton left a comment

Choose a reason for hiding this comment

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

Couple small things, otherwise nice improvement!

@chloerice chloerice force-pushed the message-indicator-color-system branch 2 times, most recently from c00a89f to 93846b9 Compare November 20, 2019 21:28
@chloerice chloerice requested a review from tmlayton November 20, 2019 21:33
@chloerice chloerice dismissed tmlayton’s stale review November 20, 2019 21:34

(Made all requested changes)

Copy link
Contributor

@tmlayton tmlayton left a comment

Choose a reason for hiding this comment

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

👍

@chloerice chloerice force-pushed the message-indicator-color-system branch 2 times, most recently from e686b73 to c433d3a Compare November 22, 2019 16:13
Copy link
Contributor

@tmlayton tmlayton left a comment

Choose a reason for hiding this comment

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

:shipit:

@chloerice chloerice force-pushed the message-indicator-color-system branch from c433d3a to 1c04a7c Compare November 26, 2019 17:15
@chloerice chloerice force-pushed the message-indicator-color-system branch from 1c04a7c to 82f73c1 Compare November 26, 2019 19:05
@chloerice chloerice merged commit b0085a7 into master Nov 26, 2019
@chloerice chloerice deleted the message-indicator-color-system branch November 26, 2019 19:14
@dleroux dleroux temporarily deployed to production December 4, 2019 14:42 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants