Skip to content

Commit ab5c65b

Browse files
authored
qns/guides: address user feedback (#489)
1 parent 397e081 commit ab5c65b

File tree

9 files changed

+31
-19
lines changed
  • packages
    • behavioral-interview-guidebook/contents/overview
    • front-end-interview-guidebook/contents
    • quiz/questions/what-is-css-selector-specificity-and-how-does-it-work
    • react-interview-playbook/contents/react-thinking-declaratively
    • system-design/contents

9 files changed

+31
-19
lines changed

packages/behavioral-interview-guidebook/contents/overview/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ In addition to these, interviewers can also mark if there wasn't sufficient info
3838

3939
Ratings have to be done with regard to the situation's complexity. A more difficult or complex situation handled well will typically receive a higher rating and leveling recommendation.
4040

41-
At the end of the interview do they reconcile all the ratings and qualitative feedback to decide:
41+
At the end of the interview they reconcile all the ratings and qualitative feedback to decide:
4242

4343
- Whether to pass or fail the candidate
4444
- If passed, what level the candidate should receive

packages/front-end-interview-guidebook/contents/overview/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Here's a summary of the question types asked by the top US companies.
132132
- **JavaScript**: Implement a function/class in JavaScript that is related to the front end domain.
133133
- **UI**: Build a user interface using HTML/CSS/JavaScript. Some companies allow you to use a framework of your choice while some only allow Vanilla JS/certain frameworks.
134134
- **System design**: Design a system and discuss the architecture and its components.
135-
- **Behavioral**: Discuss specific your experience working with others and how you handled difficult scenarios.
135+
- **Behavioral**: Discuss your specific experience working with others and how you handled difficult scenarios.
136136

137137
## Study and practice
138138

packages/front-end-interview-guidebook/contents/quiz/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ There usually wouldn't be interview rounds just asking you solely quiz questions
3232
- **System design round**: Like in the coding round, the interviewer can ask further questions on the things you say.
3333
- **Hiring manager round**: Hiring manager rounds are usually not meant to be technical but they could be going over your resume and asking you related quiz questions on technologies/projects mentioned in your resume.
3434

35-
As you can see, you can be expect to be asked quiz questions in almost every possible round. Be prepared at all times.
35+
As you can see, you can expect to be asked quiz questions in almost every possible round. Be prepared at all times.
3636

3737
## Important concepts
3838

packages/front-end-interview-guidebook/contents/user-interface-components-api-design-principles/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function Slider({ label, value, className, classNameLabel, classNameTrack }) {
142142
{label}
143143
</label>
144144
<input
145-
className={clsx('gfe-slider-range', classNameRange)}
145+
className={clsx('gfe-slider-range', classNameTrack)}
146146
id={id}
147147
type="range"
148148
value={value}

packages/front-end-interview-guidebook/contents/user-interface-questions-cheatsheet/en-US.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Most UI questions in interviews will require state and designing the state well
3434

3535
- **Determine the minimum state needed in your UI**: The smaller the state, the easier it is to read and understand the code -> lower likelihood for bugs. Identify essential state vs derived state. Derived state is state that can be calculated from essential state. By deriving the state on-the-fly you reduce the possibility of state values going out-of-sync.
3636
- **Separate rendering code vs data management code**: Make the UI a function of your data and separate your code into two parts (rendering code vs data management code) for better readability. If you use JavaScript frameworks such as React, you will more or less be forced to do so.
37-
- **Use the state-reducer pattern for complex state interactions**: If the question requires many state fields and certain actions require changing multiple fields at once, use a [reducer to consolidate state update logic](https://beta.reactjs.org/learn/extracting-state-logic-into-a-reducer). First popularized by Redux, the state-reducer pattern encourages you to determine the state of your UI, actions that can be taken, and how to combine actions with state to derive the next state. If you are using React, you can achieve this pattern via the [`useReducer` React hook](https://reactjs.org/docs/hooks-reference.html#usereducer). Redux is usually overkill for interviews and `useReducer` should be sufficient.
37+
- **Use the state-reducer pattern for complex state interactions**: If the question requires many state fields and certain actions require changing multiple fields at once, use a [reducer to consolidate state update logic](https://beta.reactjs.org/learn/extracting-state-logic-into-a-reducer). First popularized by Redux, the state-reducer pattern encourages you to determine the state of your UI, actions that can be taken, and how to combine actions with state to derive the next state. If you are using React, you can achieve this pattern via the [`useReducer` React hook](https://react.dev/reference/react/useReducer). Redux is usually overkill for interviews and `useReducer` should be sufficient.
3838

3939
[React's](https://beta.reactjs.org) docs on ["Managing State"](https://beta.reactjs.org/learn/managing-state) is an excellent resource on how to design and use component state correctly. Some of the ideas mentioned aren't specific to React and can be applied to any UI frameworks.
4040

@@ -80,7 +80,7 @@ Does your UI provide a great user experience?
8080
- Make interactive elements like buttons large enough to be pressed (recommend at least 44 x 44 px) and spaced widely enough.
8181
- **Error states**: Reflect errors promptly and clearly — form validation errors, network request errors.
8282
- **Handle rendering images of different dimensions**: Make your UI work for rendering images of all sizes/dimensions yet preserving the original aspect ratios.
83-
- Use CSS `background-image` together with `background-position: contain` so that the image fits within your defined area. If it is ok for the image to be cropped off (e.g. for gradient backgrounds), use `background-position: cover`.
83+
- Use CSS `background-image` together with `background-size: contain` so that the image fits within your defined area. If it is ok for the image to be cropped off (e.g. for gradient backgrounds), use `background-size: cover`.
8484
- `<img>` tags have a similar `object-fit` property with `contain` and `cover` values.
8585
- **Optimistic updates**: Advanced technique where the success state is reflected even though the network request is still pending. If the request fails, revert the UI changes and show an error message.
8686

@@ -136,7 +136,7 @@ There's probably not enough time to handle all edge cases scenarios in your code
136136
- **Too many items in a list**: Showing too many items on a single page can lead to poor UX (user has to scroll a lot) and poor performance in terms of responsiveness and memory consumption.
137137
- **Pagination**: Break up a long list of items into multiple pages.
138138
- [**Virtual lists**](https://www.patterns.dev/posts/virtual-lists): Rendering only visible rows of content in a dynamic list instead of the entire list.
139-
- Truncate the excess content and show an ellipsis. The `word-break` CSS property will come in handy useful.
139+
- Truncate the excess content and show an ellipsis. The `word-break` CSS property will come in handy.
140140
- Limit the content to the first X characters/words and hide the excess content behind a "Show More" button.
141141

142142
## Performance
@@ -151,7 +151,7 @@ There's probably not enough time to handle all edge cases scenarios in your code
151151

152152
- **Cross-site Scripting (XSS)**: Avoid assigning to [`Element.innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) or React's `dangerouslySetInnerHTML` when rendering contents into the DOM if it comes from users to prevent cross-site scripting, assign to [`Node.textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent) or use the experimental[`Element.setHTML()`](https://webdocs.dev/en-us/docs/web/api/element/sethtml) method instead. Refer to [OWASP's XSS Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html)
153153
- **Output encoding for "URL Contexts"**: If user-supplied input can be used in URL query parameters, use `encodeURIComponent` to prevent unintended values from becoming part of the URL (e.g. extra query parameters).
154-
- **Cross Site Request Forgery**: Refer to [OWASP's XSS Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html).
154+
- **Cross Site Request Forgery**: Refer to [OWASP's CSRF Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html).
155155

156156
## Internationalization (i18n)
157157

packages/quiz/questions/what-is-css-selector-specificity-and-how-does-it-work/en-US.mdx

+20-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,27 @@
22
title: What is CSS selector specificity and how does it work?
33
---
44

5-
The browser determines what styles to show on an element depending on the specificity of CSS rules. We assume that the browser has already determined the rules that match a particular element. Among the matching rules, the specificity, four comma-separate values, `a, b, c, d` are calculated for each rule based on the following:
5+
When multiple CSS rules could apply to the same HTML element, the browser needs a way to decide which rule takes precedence. This is determined by the **CSS cascade**, which considers importance, inline styles, selector specificity, and source order. **Selector specificity** is a key part of this process, calculating a weight for each selector.
66

7-
1. `a` is whether inline styles are being used. If the property declaration is an inline style on the element, `a` is 1, else 0.
8-
1. `b` is the number of ID selectors.
9-
1. `c` is the number of classes, attributes and pseudo-classes selectors.
10-
1. `d` is the number of tags and pseudo-elements selectors.
7+
The browser determines what styles to show on an element depending on the **specificity** of the CSS rules that match it. Specificity is calculated for each rule to decide which one takes precedence.
118

12-
The resulting specificity is not a single numerical score, but an array of values that can be compared column by column. When comparing selectors to determine which has the highest specificity, look from left to right, and compare the highest value in each column. So a value in column `b` will override values in columns `c` and `d`, no matter what they might be. As such, specificity of `0, 1, 0, 0` would be greater than one of `0, 0, 10, 10`.
9+
## How is specificity computed?
1310

14-
In the cases of equal specificity: the latest rule is the one that counts. If you have written the same rule into your stylesheet (regardless of internal or external) twice, then the lower rule in your stylesheet is closer to the element to be styled, it is deemed to be more specific and therefore will be applied.
11+
The specificity algorithm is basically a three-column value of three categories or weights - ID, CLASS, and TYPE - corresponding to the three types of selectors. The value represents the count of selector components in each weight category and is written as `ID - CLASS - TYPE`. The three columns are created by counting the number of selector components for each selector weight category in the selectors that match the element.
1512

16-
It's a better practice to write CSS rules with low specificity so that they can be easily overridden if necessary. When writing CSS UI component library code, it is important that they have low specificities so that users of the library can override them without using too complicated CSS rules just for the sake of increasing specificity or resorting to `!important`.
13+
1. **ID**: This is the count of ID selectors (e.g., `#example`).
14+
2. **CLASS**: This is the count of class selectors (e.g., `.my-class`), attribute selectors (e.g., `[type="radio"]`), and pseudo-classes (e.g., `:hover`).
15+
3. **TYPE**: This is the count of type selectors (element names, e.g., `h1`, `div`) and pseudo-elements (e.g., `::before`).
16+
17+
When comparing selectors to determine which has the highest specificity, look from left to right (ID, then CLASS, then TYPE), and compare the highest value in each column. A value in the ID column will override values in the CLASS and TYPE columns, no matter how large they are. Similarly, a value in the CLASS column overrides any value in the TYPE column. For example, a specificity of `1,0,0` (one ID) is greater than `0,10,10` (ten classes and ten types).
18+
19+
It's important to remember that specificity is part of the broader **CSS cascade**. Declarations marked `!important` have the highest precedence, followed by inline styles (using the `style` attribute). Selector specificity comes next.
20+
21+
In cases of **equal specificity** among competing rules (that aren't inline or `!important`), the rule that appears **last** in the CSS source order is the one that counts and will be applied.
22+
23+
It's a better practice to write CSS rules with low specificity so that they can be easily overridden if necessary. When writing CSS for UI component libraries, it is important that styles have low specificities so that users of the library can customize them without needing overly complex selectors or resorting to `!important`.
24+
25+
## References
26+
27+
- [Specificity | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascade/Specificity)
28+
- [Specificity | web.dev](https://web.dev/learn/css/specificity)

packages/react-interview-playbook/contents/react-thinking-declaratively/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Actions are triggered in response to two kinds of events:
164164

165165
For the todo list at hand, we only need to care about user events.
166166

167-
However, it is advisable to write a function for each of these actions, and call the state setters within each action function. This is because the same operation can be triggered from many places on the UI, or even in the background. An example is a video player where there to pause the video, users can either press the "Pause" button or press the spacebar.
167+
However, it is advisable to write a function for each of these actions, and call the state setters within each action function. This is because the same operation can be triggered from many places on the UI, or even in the background. An example is a video player, where, to pause the video, users can either press the "Pause" button or press the spacebar.
168168

169169
Centralizing state update logic within these action functions will help to keep the code maintainable.
170170

packages/system-design/contents/introduction/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ As you can see, the focus of front end system design interviews can be very diff
4242

4343
## What you will learn in this guide
4444

45-
Our Front End System Design guide is structured into two parts, you will first gain a deeper understanding system design interviews are about, then dive into some front end system design case studies that use the RADIO framework.
45+
Our Front End System Design guide is structured into two parts, you will first gain a deeper understanding of what system design interviews are about, then dive into some front end system design case studies that use the RADIO framework.
4646

4747
- [Types of questions](/system-design/types-of-questions): Types of Front End System Design interview questions and examples
4848
- [RADIO framework](/system-design/framework): A framework for answering Front End System Design interview questions

packages/system-design/contents/types-of-questions/en-US.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ There are two main kinds of front end system design questions: (1) Applications
1212

1313
As mentioned above, designing applications for front end system design interviews will feel similar to general Software Engineering system design interviews, and in fact, the questions are highly similar. However, instead of talking about distributed systems, you should focus on the client side of things and talk about application architecture and client-side implementation details.
1414

15-
In this day and age, many websites are interactive and rich applications that can do virtually what many desktop applications can. If you've used Gmail, Facebook, YouTube, ChatGPT, or Google Calender on the web, you'd have used a web app. Web apps tend to be interactive and dynamic (contents on the page change frequently) and page navigations in a web app usually don't require a full page refresh; the app uses JavaScript to fetch remote data for the next page and dynamically change the contents and URL.
15+
In this day and age, many websites are interactive and rich applications that can do virtually what many desktop applications can. If you've used Gmail, Facebook, YouTube, ChatGPT, or Google Calender on the web, you have used a web app. Web apps tend to be interactive and dynamic (contents on the page change frequently) and page navigations in a web app usually don't require a full page refresh; the app uses JavaScript to fetch remote data for the next page and dynamically change the contents and URL.
1616

1717
Since web apps are complex software involving multiple modules, common application architectures learnt in Software Engineering classes like Model-View-Controller (MVC), Model-View-ViewModel (MVVM) are also applicable when building web apps. React is one of the most popular JavaScript libraries by Facebook to build interactive web applications and many React web apps adopt a unidirectional Flux/Redux-based architecture.
1818

0 commit comments

Comments
 (0)