Provide a clear prompt that follows best practice when providing instructions to a LLM. The goal of the prompt is to generate a document highlighting all possible use-cases for the getColor utility found in the ./packages/theming folder via examples written in react and styled-components. It should also highlight recommended patterns and discourage bad use. Give me 3 options. Use your best judgement. Double check your work.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Okay, here are three prompt options designed to guide an LLM in generating documentation for the getColor utility, emphasizing best practices, examples, and common pitfalls.
Option 1: Focused on Clarity and Structure
code
You are an expert technical writer specializing in React and styled-components. Your task is to create a comprehensive document explaining the usage of the `getColor` utility from the `@zendeskgarden/react-theming` package. This document will serve as a guide for developers using this utility.
**Structure:**
1. **Introduction:** Briefly introduce the `getColor` utility and its purpose within the theming context of `@zendeskgarden/react-theming`.
2. **Core Functionality:** Explain how `getColor` works, emphasizing its parameters: `dark`, `hue`, `light`, `offset`, `shade`, `theme`, `transparency`, and `variable`. Clearly define the data types expected by each parameter and explain how they interact with the theme object.
3. **Use Case Examples:** Provide at least 5 distinct examples demonstrating various applications of `getColor` within React components styled with `styled-components`. Each example should include:
* A clear description of the scenario and the intended outcome.
* A code snippet using `getColor` correctly within a styled component using the `useTheme` hook.
* A brief explanation of why that specific `getColor` pattern is being used.
* Example use-cases should include:
* Basic color retrieval using a variable.
* Adjusting a base color with `shade` and `offset`.
* Applying light and dark variants.
* Modifying colors using `transparency`.
* Using `hue` for color manipulation.
4. **Recommended Patterns:** Highlight patterns for usage that are considered good practice. For example:
* Use variables to reference theme colors for consistency and maintainability.
* Use named variables for clarity (`background.primary` instead of a magic string).
* Combine `getColor` with the `useTheme` hook for dynamic theme access.
5. **Anti-Patterns/Discouraged Usage:** Specifically point out common mistakes or usage patterns that should be avoided. This includes:
* Hardcoding colors when theme variables exist.
* Overly complex or nested color manipulations.
* Misusing `shade`, `offset`, and `transparency`, which are only applicable to the palette.
* Directly mutating the theme values.
6. **Error Handling:** Show an example how to handle error when getColor fails.
7. **Conclusion:** Summarize the key takeaways and provide additional resources where applicable.
**Output Format:** The output should be a markdown document suitable for direct inclusion in a project's documentation. Ensure code snippets are correctly formatted and syntax highlighted. Maintain a professional, concise and easily readable style. Use the information within the provided files to generate the examples.
Option 2: Emphasis on Problem Solving and Practical Application
code
You are a senior React developer tasked with documenting the `getColor` utility from `@zendeskgarden/react-theming`. Your goal is to create documentation that teaches developers how to effectively use `getColor` to solve real-world styling problems in their applications.
**Document Structure:**
1. **Problem:** Start with a description of the problem `getColor` solves. Explain why managing theme colors can be complex and why a utility like `getColor` is essential.
2. **Solution Overview:** Introduce the `getColor` utility as the solution and describe its role within the Garden theme system. Explain what data types it expects as parameters.
3. **Practical Examples (Problem & Solution):**
* Present realistic scenarios where `getColor` is needed. For each scenario:
* **Problem:** Describe the styling challenge (e.g., needing a button background color that changes on hover, having to implement a color scheme based on user preference, needing to derive a shade of blue, etc).
* **Solution:** Provide the React/styled-components code using `getColor` to solve the problem, along with a detailed explanation of how the code works.
* **Why:** Explain why this particular implementation with `getColor` is the correct way of handling that styling scenario.
* Include examples for the following:
* Basic color retrieval by a theme variable.
* Adjusting colors with `shade`, `offset` parameters (showing that these parameters must be used with a palette color, not a base color).
* Applying light and dark variants based on theme.
* Modifying colors with transparency.
* Modifying colors with hue.
* Ensure the examples show how to use `getColor` in a styled component with `useTheme` hook.
4. **Best Practices:** Distill the examples into a list of best practices. Focus on when and why specific parameter combinations are useful.
5. **Common Mistakes and How to Avoid Them:** Explain potential pitfalls like hardcoding values, overusing modifiers, and direct theme mutations. Provide clear instructions on how to avoid them. Show an example of how to handle errors thrown by getColor.
6. **Further Exploration:** Briefly suggest additional learning resources or related concepts.
**Output:** Your response should be a well-organized markdown document that is easy to read and understand. Use clear language, code examples, and explanations. Use the information within the provided files to generate the examples.
Option 3: Focus on API and Usage Specifics
code
You are an experienced API documentation writer focusing on React and styled-components. Your task is to produce detailed documentation for the `getColor` utility within the `@zendeskgarden/react-theming` package. This documentation should be precise and serve as a reference guide.
**Document Content:**
1. **Introduction:** Start with a concise introduction explaining the purpose of `getColor`.
2. **API Reference:** Provide a detailed breakdown of the `getColor` function, covering:
* **Function Signature:** Clearly show the function's input parameters (`dark`, `hue`, `light`, `offset`, `shade`, `theme`, `transparency`, `variable`) and expected return type.
* **Parameter Explanations:** Explain each parameter in detail, specifying:
* Its data type, whether it's optional, and what it represents within the theme system.
* How each parameter influences the output color.
* Special conditions of usage (e.g. `shade` and `offset` must be used in conjunction with a palette color, not a base color).
* What type of theme object does the parameter `theme` expect.
* What type of variable is expected.
* **Return Value:** Specify what the function returns (a color value).
* **Error Handling:** Specify what errors the function can throw, and why.
3. **Usage Examples:** Provide several practical examples, focusing on different parameter combinations. Each example should:
* Be written in React with styled-components using the `useTheme` hook.
* Include the code snippet and an explanation of what the parameters achieve.
* Include the corresponding description of the example use-case.
* Include examples for retrieving color from:
* A theme variable.
* A base color, with adjustments for `shade`, `offset`, and `transparency`.
* A hue color.
* Light and dark color variations.
4. **Best Practices:**
* Recommend usage patterns that leverage the full power of the API while being maintainable. Include usage of named variables.
5. **Pitfalls:** Explain incorrect use cases of the API, and why that is bad practice.
**Output Format:** Your output should be a structured markdown document with clear headings, code blocks, and explanations. Provide a comprehensive reference that a developer could use to quickly understand and use `getColor`. Use the information within the provided files to generate the examples.
Explanation of Choices:
Option 1 (Clarity and Structure): Emphasizes a well-organized document, suitable for users who prefer a comprehensive, step-by-step guide.
Option 2 (Problem Solving): Focuses on practical problem-solving, appealing to developers who learn by seeing real-world application. This makes the documentation more relatable.
Option 3 (API Specifics): Focuses on the API itself, making it useful for developers who need a quick, detailed reference for the getColor function.
All prompts encourage the use of provided file context, specifically the GetColorStory.tsx file which provides valid examples, and the README.md file that outlines the purpose of the theming package. All prompts instruct the LLM to highlight error handling.
I've double-checked to ensure clarity, specificity, and alignment with the user's goal. Let me know if you'd like any adjustments!