airbnb / lunar Goto Github PK
View Code? Open in Web Editor NEW๐ React toolkit and design language for Airbnb open source and internal projects.
License: MIT License
๐ React toolkit and design language for Airbnb open source and internal projects.
License: MIT License
I've set up a minimal test project to give this library a try but I can't seem to get it working. It's always throwing out the following error:
Uncaught Error: Aesthetic has not been initialized. Please call
Core.initialize()
from@airbnb/lunar
.
Here is my test file.
import React from 'react'
import ReactDOM from 'react-dom'
import Core from '@airbnb/lunar';
const log = (...args: object[]) => console.log(...args);
Core.initialize({
logger: log,
name: 'TestLunar',
});
import { Button } from '@airbnb/lunar/lib/components/Button';
ReactDOM.render(
<Button>Test Button</Button>,
document.getElementById('react-root')
)
I'm using parceljs as bundler for this project if it matters.
compact
from forms.Props
to <CompName>Props
(same for State
).Card
for better customization.withStyles
to useStyles
(unless component cannot be changed from a class). Any APIs that relied on extendStyles
should now accept a styleSheet
prop.textProps
to Link
and other components that may need it.Tabs
(for list of acceptable keys).Hi, I import some third party stylesheets. But some styles not work becase of lunar has inject some global styles with !important
If I force let globals
to be null in here. My app will work well
So is there any general way to fulfill my needs?
Right now non-fluid layouts have a max width, but there's no way to center the layouts on the screen. There should be a center
prop on the layout that adds margin: auto
on the container so that it is visually centered.
@milesj @lencioni Thanks for looking into that issue I reported a while back. There's a more serious one I wish to report, after the official channels didn't work out.
The issue is that reviews are entered and displayed in sanitized HTML, but with whitespace preserved verbatim, instead of being replaced with
and <br />
s. This causes consecutive whitespace to collapse into one, rendering carefully-formatted reviews as walls of text.
Here's an example of a review where the author took time to format it intelligibly, which looks very hard to read on the site:
I believe the change made in #287 resulted in Overlays not rendering if the open
param is set to true initially. This seems to be because the Overlay doesn't render its children until it updates once, and if we initialize open to true then it never updates.
You should be able to repro this with a simple case like:
<Overlay open={true} onClose={() => undefined}>
<div>This doesn't display</div>
</Overlay>
Hi, I use the ESLint config from Lunar as a base for all my React/TypeScript projects, so how about publishing it as a package?
The eslint-config-airbnb
is really great and is used by so much people out there, but when you start using TypeScript, you always find yourself overriding everything... I know there is this project: https://github.com/iamturns/eslint-config-airbnb-typescript, but Lunars config is so much more - so why not make it official? ๐
I would like to add the muted option to FilterMenu.
It should just be a pass through to the underlying MenuToggle.
If folks are open to it, I would be happy to put a PR up for this.
When an input is in a valid state, a purple border appears that shows keyboard only users that an input is focused for typing.
However, when the input is in an error state, there is no focus indicator
This is important for accessibility so keyboard only users know that they are typing into the expected field. I would suggest using the outline css field for focused elements or using box shadow rather than border color.
Leave
In the past we used Jest snapshots for testing React components, but they are brittle and constantly need updating. For legacy reasons, we haven't removed them all yet... but we should.
Not sure if this is intentional, but I see here partitionFieldProps
sets value = ''
for all form fields every time they render:
lunar/packages/core/src/components/FormField/partitionFieldProps.ts
Lines 68 to 71 in e378004
This basically makes an input unusable without a state
bind to input.value
. Even the most basic input example in the Storybook does not work (users cannot type anything).
It's generally a bad practice to write what users typed right back into an input. It triggers an unnecessary re-render, increases the risk of circular callbacks and greatly increases code complexity. For example, a PR in Bighead had to introduced a new state just to use a debounced onChange
handler.
Code as simple as
export default function DebouncedInput(props: DebouncedInputProps) {
const { onChange, debounceTime = 150, ...restProps } = props;
const handleChange = debounce(onChange, debounceTime);
return <Input {...restProps} onChange={handleChange} />;
};
had to change to
export default function DebouncedInput(props: DebouncedInputProps) {
const { onChange, debounceTime = 150, ...restProps } = props;
const [value, setValue] = useState(restProps.value);
const handleChange = debounce(onChange, debounceTime);
return <Input {...restProps} value={value} onChange={(
newValue: string,
event: React.ChangeEvent<HTMLInputElement>
) => {
setValue(newValue);
handleChange(newValue, event);
}} />;
}
And most importantly, manually setting user input as users type has the side effect of interfering with other native browser behaviors, breaking things like autocomplete and foreign language input (I've seen such bugs many many times).
In case a clean input is desired, developers should provide value=""
themselves.
The fix is as simple as remove value: ''
. If this change would break current developer expectations or other features, it's the best to at least provide an option to disable this behavior.
Would a PR for this be welcome? I'm interested in contributing this.
Styleguidist has served us well but Storybook 5 looks real nice. It provides themeing (which we need for dark mode), a11y checks (which we also need), responsive utils, and more.
Users may close modal by mistake when they accidentally click outside the modal and lose all the form states in the modal.
We need a maskClosable
prop for Modal to control whether nor not auto close modal when click outside the modal.
The Form
component support throwing error in its onSubmit
callback and renders the error message. But I my application, the FormAction
is not reset to enabled even if I modify the input.
Full example: https://codesandbox.io/s/trusting-brown-42suu
Root cause:
A possible solution:
export default function FormActions(props: FormActionsProps) {
const form = useForm();
// this line changed
const { submitting, valid, dirtySinceLastSubmit } = form.getState();
return (
<BaseFormActions
{...props}
// this line changed
disabled={!dirtySinceLastSubmit && !valid}
processing={submitting}
/>
);
}
Apologies for the OT bug. I chose this repo because I couldn't find one for the website, this one had recent activity, and not a lot of people would be spammed by the bug.
The issue is that the source code for the site is clearly visible due to Gatsby generating source maps for production builds by default. For example, comments like the one in the screenshot below are visible.
Was it intended to have the source maps exposed in production?
after switching to storybook 5, would be nice to have/look into:
It seems that loadItemsOnMount
implies autoFocus
. This leads to some undesirable behavior if, for example, you apply this to multiple Autocomplete components on the same page.
Autocomplete component does not fire onLoadOptions
callback for empty string input. (The only time onLoadOptions
is fired for an empty string is when loadItemsOnMount
is true
.)
The built-in caching 5 minutes of autocomplete items cannot be disabled or configured.
The combination of issue 2 and 3 leads to some other edge cases.
Finally, just a side remark, the naming seems a bit inconsistent, as in loadItemsOnMount
vs. onLoadOptions
. Could be more clear if this was items everywhere.
Currently <Tooltip>
forces the tooltip trigger container to be inline-block, but sometimes it's more desirable to make it a block, e.g, when you want to show tooltips for the whole table cell.
In the above table, tooltips only show up when users hover over the date text, but it would be nicer if it can show up as soon as users hover on a date cell. Currently it's not possible to do so.
HierarchyPicker fuseOptions prop is passed to Picker.
But fuseOptions is missing in PickerProps. Neither do Search get this prop too.
Per aesthetic-suite/framework#127, Aesthetic is using an outdated version. How about an update?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.