Giter VIP home page Giter VIP logo

yamui's Introduction

YamUI Travis

Please note that YamUI is now in maintenance mode and only minor changes will be made to support existing Yammer applications. If you are using YamUI in your own projects we'd recommend locking your version to 9.4.1, or forking the project from this commit before we rolled back some features in the 10.0.0 release. Thanks!

This is the UI component framework for Yammer.com.

It is built with React on top of Office UI Fabric components. Unit tests are run through Jest, isolated development environment and documentation is provided by Styleguidist, and visual diff regression is done with Puppeteer and pixelmatch. Visual diff tasks run within a Docker container to ensure consistency between local development environments and CI.

Using YamUI in your own app

If necessary, add YamUI to your project.

npm install --save yamui

Importing the baseline CSS

Import yamui/dist/yamui-base.css into your app. You could link to it directly before your own CSS, or import it through JS/CSS and include it at the top of your CSS bundle. This file is currently about 4kb minified+gzipped. This is a requirement as YamUI expects to own the baseline styles of the page.

Using components

You can read all documentation for our components in our living styleguide.

Each component is compiled from its TypeScript source into yamui/dist/components. This allows you to import the individual components you need and keep your bundle size smaller. Note that each component may import its own CSS and other JS dependencies so you may need to adjust your build process to accommodate.

Example importing a Button component:

import Button, { ButtonSize, ButtonColor } from 'yamui/dist/components/Button';

Example using a Button component:

<Button size={ButtonSize.SMALL} color={ButtonColor.SECONDARY} text="Click me!" />

Installation

git clone https://github.com/Microsoft/YamUI.git
cd YamUI
npm install

To run visual diff regression tests:

  • Install Docker (Docker for macOS / Docker for Windows).
  • Create an alias y in your ~/.zshrc or ~/.bashrc file for the yamui-docker executable that looks like alias y="./yamui-docker". Visual diff tasks need to run in Docker via the y alias, e.g. y run test and y run test:visual.

It's best to have at least 30GB of free space for Docker containers and images. If you find that Docker is taking up too much space, try the following:

  • View your Docker container size (on macOS): ls -lha ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
  • Clear space:
    • Remove all images: docker rmi $(docker images -a -q)
    • Remove all exited containers: docker rm $(docker ps -a -f status=exited -q)
    • Remove everything from disk, directly (on macOS): rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

Development

Starting up the dev server

Building some components

  • npm run create:component and provide the necessary information.
  • Tweak <ComponentName>.md file in your component's directory with usage examples. These examples are important because they document how components should be used and what options/configurations they accept. These examples will also be used in visual diff regression tests to ensure new changes are deliberate and approved before PRs are merged.
  • The dev server will pick up any changes you make to components, and automatically update the app in your browser using Hot Module Replacement.

Writing unit tests

  • npm run watch:jest will start Jest in watch mode, showing passing status and a coverage report. The CLI task remains active and will re-test automatically as you make changes.

Running visual diff regression tests

  • y run test:visual will compile the components, build+export a static version of the styleguide, start a dev server, take screenshots of each example, and fail if there are visual changes from the last approved screenshots. Unless you're developing on a Linux computer, this task must run within the Docker container via the y shortcut. Running via npm run on Mac or Windows will use your OS version of PhantomJS Webkit and will fail with subtle visual differences. Running in the Docker Linux container ensures consistent screenshots between all development environments and CI.
  • npm run test:visual:approve will approve your latest test images and overwrite the previous reference images. Use this when you are deliberately changing a component or its examples and you have manually verified that the new visual changes are correct.
  • y run test:visual:component <ComponentName> will do the same as y run test:visual, but only test the specified component. This allows for faster iterations during development.

Testing all the things

  • y run test will run all validations - linting, unit tests and visual diff regression tests. If this passes you should be all good to go.

Adding icons

Releasing a new version

If you want to release a new version of YamUI, do the following to create a release branch. Replace version_type with major, minor or patch as appropriate, based on SemVer:-

git checkout -b awesome-release-branch
npm version version_type -m "Release version %s"
git push
git push --tags

This will add a commit that updates package.json and package-lock.json with the updated version number.

Once this branch's PR is merged to master, do the following to publish the release so it can be consumed from npm:-

# requires an npm user with permissions to release
git checkout master
git pull
npm install
npm publish

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Licenses

All files on the YamUI GitHub repository are subject to the MIT license. Please read the LICENSE file at the root of the project.

Note that we depend on Fabric for fonts. Usage of the fonts and icons referenced in YamUI is subject to the terms of the assets license agreement.

yamui's People

Contributors

adrianmg avatar andre-taylor avatar annr avatar brendanmck avatar brmckeon avatar cainhimself avatar chrismohr avatar dan5382 avatar dependabot[bot] avatar dokarns avatar dreadwail avatar eoh avatar hxkoh2 avatar ipadthree avatar jessemartin avatar kant avatar logrologist avatar machineloop avatar mamuso avatar microsoftopensource avatar msftgits avatar peterblazejewicz avatar rahultiru avatar rese avatar richardtagger avatar sbalentine avatar swese44 avatar tonyja avatar unindented avatar yellowapple avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yamui's Issues

Consider an alternate solution for CSS styling

We take a strong stance against metaprogramming for good reason. In CSS this means avoiding dynamic construction of classnames/selectors so we can easily find those classnames and selectors in our codebase.

This makes a lot of sense in our large application repo. It's not as much of a concern in YamUI where we know exactly where a component's CSS lives.

We currently have several CSS files where selectors for enumerated values like padding/gutters/font-sizes are manually copy+pasted. This is error prone and requires us to own more lines of code. It could be nice to take advantage of PreCSS to make this code more DRY. A few examples:
https://github.com/Microsoft/YamUI/blob/master/src/components/Block/Block.css#L10
https://github.com/Microsoft/YamUI/blob/master/src/components/FixedGrid/FixedGrid.css#L9
https://github.com/Microsoft/YamUI/blob/master/src/components/LayoutList/LayoutList.css#L26
https://github.com/Microsoft/YamUI/blob/master/src/components/Text/Text.css#L43

Another option would be to use a CSS-in-JS solution. We could use Fabric's styling package to avoid additional overhead, and this would allow us to remove CSS classes/logic for gutter sizes, padding, etc.

Make it easier to create a new component

@rese had trouble creating a new component. Styleguidist only recognizes class components, not function components. Also copying an existing folder and renaming things is complex and error prone.

Maybe we can provide a yeoman generator?

Add screenreaderText prop to Text component

This will use aria-hidden to hide the Text component's content from screenreaders while rendering a ScreenreaderText component with the given string. Note that Text's render() method will need to return 2 elements (one visible, one available for screenreaders), so either needs additional markup to expose the screenreaderText, or wait until clients upgrade to React 16.2 and return a Fragment

Button aria attributes

Button's aria-labelledby attribute has a number value, should be removed entirely? Maybe aria-disabled isn't necessary if disabled is already present?

Component: Tooltip

Ready to go to start implementation.

Make sure to ping me or Manuel to make a review before starting to implement anything so we can tackle issues, questions, and doubts in advance.

http://zpl.io/VKEe8d7

Simplify component examples, separate visual-diff-only examples

It's a little hard to read the docs as many components have several and/or complicated examples. We should move anything that's only for visual diffs to a new section. Proposal:

Sections:

  • Intro. How to consume YamUI in your app
  • Components. Simple, clear docs on what a component does, what it should or shouldn't be used for, and simple examples for relevant props. Maybe in the future break them up into categories (layout, forms, interactive components) but not necessary at the moment.
  • Demos. Examples of common component compositions - hovercards, button action bars, etc.
  • Visual tests. These are really only there for visual tests and shouldn't be clogging up the component docs. Would be nice to keep these near their respective components though, maybe use a naming convention like ComponentName.visual.md?

and continue visual-diffing all examples

Restrict SuggestionsList to vertical alignment

Need to add a new directionalHint option to Fabric's Callout. Ideas:

  1. Add prop directionalHintFixedAxis = 'horizontal' | 'vertical' to restrict placement to only top/bottom or only left/right
  2. Add directionalHintAllowedPlacements = DirectionalHint[] to provide a list of allowed positions the Callout can be aligned to

TS6059 Error: 'rootDir' is expected to contain all source files

The index.ts file is now copied to public output directory:
https://github.com/Microsoft/YamUI/blob/master/config/icons/generate.js#L30
which seems to be the reason I'm getting this error when running local dev server via npm start:

Failed to compile.
/Users/piotrblazejewicz/git/YamUI/tsconfig.json
[tsl] ERROR
      TS6059: File '/Users/piotrblazejewicz/git/YamUI/dist/components/Icon/icons/index.ts' is not under 'rootDir' '/Users/piotrblazejewicz/git/YamUI/src'. 'rootDir' is expected to contain all source files.

full output: https://gist.github.com/peterblazejewicz/54a0db7fe4f7d540b95ff02c2da11616

I though about changing tsconfig.json excluding dist directory sources (*.ts)

Thanks!

Extract Examples

From #127:
"As a solution, I was thinking of using the updateExample property, extracting all examples to their own separate files, and compiling them with tsc. That'd also solve the issue you cited of not being able to use your IDE to write examples."

Persona shows flash of color/initials even when passing image to Avatar

For example, if it's a deleted group, you might see a color flash before it displays the no_photo icon. I only mention this example because it's bright and then dull and so it stands out. Someone might think it's a peek at a deleted group image -- they see content that is quickly replaced

Remove autoprefixer

BackstopJS uses a version of PhantomJS which doesn't support flexbox and some other CSS3 styles. We should keep an eye on this issue and see if we can remove autoprefixer when it's resolved:
garris/BackstopJS#358

In the meantime we're using the same version and config as our client application

Tooltips do not work when placed in an overflow:hidden parent

Yammer message byline uses <Text maxWidth="100%"> to ellipsis extra text, which uses overflow:hidden. User names and "reply to" text use Tooltips, which will be hidden by the wrapping ellipsis.

Should probably change Tooltip to use the default layer behavior

Implement an error logging solution

For things like passing the wrong number of initials to Avatar. Do we throw errors and break the UI for customers, just log to the console for devs to see, or maybe provide a logger event emitter and let clients subscribe to error events and report them?

Links generating visual glitch on cursor

I'm attaching a video with the problem using a FakeLink component, I'm not sure if this is also happening on regular links.

Basically, the whenever you hover a link it's switching the cursor between: 'regular - text selector - pointer' generating a visual glitch that doesn't feel right.

That's not how the cursor behaves normally against interactive elements or links.

preview

Component: Lists (ordered & unordered)

Ready to go to start implementation.

Make sure to ping me or Manuel to make a review before starting to implement anything so we can tackle issues, questions, and doubts in advance.

Note: keep in mind that the numbered lists are slightly different than the default ones, the gap between the number and the label is consistent with the discs on the unordered lists (but that's not the default on CSS, we need custom stuff there). This may help: https://www.w3.org/Style/Examples/007/color-bullets.en.html

Zeplin: http://zpl.io/VkKNMXL

Module: PreviewCard

Ready to go to start implementation.

Make sure to ping me or Manuel to make a review before starting to implement anything so we can tackle issues, questions, and doubts in advance.

http://zpl.io/Vq1Ne3Z

Add color to Block

We have cases where Text is nested in Block just for color. If Block has color then these would not be necessary. It would also help people get correct line-heights easier since Block will always have the correct line-height. It will also let us remove some override CSS in MediaObject.

Provide <Fabric /> component's functionality as a utility

Fabric expects us to wrap our app in a component. This component adds font styles for the rest of the app, and will eventually handle language-specific fonts for us. We cannot wrap Yammer.com in a component since most of Yammer is not React.

Fabric engineers recognize this issue and recommend we contribute to office-ui-fabric-react by extracting the component's functionality into a utility module. This utility module would allow us to provide an HTML element and would keep its list of CSS classes (and associated glamor styles) up to date as they change.

This does not block development as our Storybook app will wrap its stories in a component, but this does block us from integrating with YamJS.

Missing border-radius

Hello, team!

Some components are missing the border-radius 1px that we tend to use resulting in hard edges that we want to avoid in the final implementation.

Examples of this are hovercards, suggestions, and pretty much all the components that are floating on top of things with a shadow applied.

@mamuso was mentioning that was related to a bug and the overflow but I'm not completely sure what that means.

Could we fix it at some point?

Module: Rightrail

Ready to go to start implementation.

Make sure to ping me or Manuel to make a review before starting to implement anything so we can tackle issues, questions, and doubts in advance.

zpl.io/anokGGJ

Visual diffs depend on CDN Segoe font, which is not always reachable

Last week I ran the visual snapshot tool on master viay run test:visual and most of the tests failed for font-related reasons. Further investigation with @unindented revealed that the Segoe font was not loading properly.

We should save a copy of the Segoe font in YamUI and reference it locally to prevent network flakiness from failing our test suite.

Component: SuggestionsList (Typeahead)

Ready to go to start implementation.

Make sure to ping me or Manuel to make a review before starting to implement anything so we can tackle issues, questions, and doubts in advance.

zpl.io/aXKp7Rj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.