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, along with explanations of why they're structured as they are:
Option 1: Focus on Comprehensive Examples and Guidance
code
You are an expert software engineer specializing in React and styled-components. Your task is to generate comprehensive documentation for the `getColor` utility function found in the `@zendeskgarden/react-theming` library. This documentation should be a standalone document (e.g., Markdown) targeted at developers who are already familiar with React and styled-components.
The documentation must:
1. **Demonstrate all valid ways to use the `getColor` function**: Provide code examples using React and styled-components that showcase every possible combination of the `getColor` arguments: `hue`, `shade`, `offset`, `transparency`, `dark`, `light`, and `variable`.
2. **Highlight Recommended Patterns**: Emphasize the most common and best-practice ways to use `getColor`, focusing on accessing theme variables and modifying them. Provide clear explanations for these use cases.
3. **Discourage Bad Use**: Identify and clearly explain patterns that should be avoided. Provide examples of these bad uses and explain why they are not recommended. For example, using hardcoded values instead of theme variables.
4. **Explain Theme Integration**: Showcase how `getColor` interacts with the `ThemeProvider` and how to properly access the theme context.
5. **Provide Clear Code Examples**: All code examples must be complete and runnable using react and styled-components. Ensure code is properly formatted and contains clear comments.
6. **Describe the Fallback Mechanism**: Detail what occurs when an invalid theme variable or combination of arguments is passed into `getColor`.
7. **Document the Return Value**: Specifically mention that the return value of `getColor` is a string representing a color, either hex, rgba, or some other accepted color value.
The goal is to equip developers with a solid understanding of how to effectively use `getColor` for theming in their React applications. The structure of the document must have a clear introduction, usage examples, good/bad patterns, and a conclusion.
Begin by creating a conceptual overview of `getColor` that sets up the context for the developer.
Option 2: Emphasis on Practical Scenarios and Problem-Solving
code
You are a senior front-end developer tasked with creating documentation for the `getColor` utility from the `@zendeskgarden/react-theming` library. The documentation should be in a format that is easy for other developers to follow and understand. Use markdown.
Create a document that explains how to use the `getColor` utility effectively, focusing on practical scenarios and problem-solving. The document should include:
1. **Real-World Examples**: Provide several real-world scenarios using `getColor` within React components styled with styled-components. For example:
* Changing the background color of a button using a primary color from the theme.
* Adjusting the shade of a color for hover states.
* Creating a semi-transparent overlay color.
* Using `dark` and `light` to make themes accessible.
2. **Detailed Code Explanation**: For each scenario, provide detailed code examples with clear comments explaining each part of the code, especially the arguments passed to `getColor`. Use functional components.
3. **Error Handling**: Clearly demonstrate how the `getColor` function handles errors and what a user should expect if they provide invalid input such as undefined variables. Showcase the fallback mechanism and how to use it effectively.
4. **Integration with `ThemeProvider`**: Explain how `getColor` relies on the `ThemeProvider` to access theme variables, using code examples for clarity. Be explicit that you must use the `useTheme` hook from styled-components.
5. **Best Practices**: Clearly call out patterns that constitute best practices when using `getColor` such as avoiding inline styles, using the theme as a source of truth and how to correctly access variables.
6. **Anti-Patterns**: Highlight common anti-patterns to avoid when using `getColor`. Explain why these are discouraged by providing examples.
7. **Return Value Documentation**: Explain that the return value of the `getColor` utility is a string that represents a color.
8. **Comprehensive Parameter Breakdown**: Thoroughly explain all parameters of `getColor` including, `hue`, `shade`, `offset`, `transparency`, `dark`, `light`, and `variable`.
The document should have a clear introduction, problem/solution sections, and should conclude by calling out the core value of the function.
Option 3: Structured Documentation with a Focus on API Reference
code
You are an experienced technical writer specializing in API documentation for UI component libraries. Generate a comprehensive documentation document for the `getColor` utility function within the `@zendeskgarden/react-theming` package. The documentation should follow a structured approach, emphasizing clarity and ease of reference using markdown.
The documentation must include:
1. **Introduction**: Begin with a concise introduction describing the purpose of the `getColor` utility and its role in theme management. Be explicit about it's usage within React and styled-components.
2. **API Reference**: Provide a detailed breakdown of the `getColor` function, including:
* **Parameters**: A comprehensive list of all parameters (`hue`, `shade`, `offset`, `transparency`, `dark`, `light`, `variable`) with their descriptions, types, and valid values. Clearly explain how parameters interact with one another.
* **Return Value**: Describe the return value (a color string) and its format (e.g., hex, rgba).
* **Error Handling**: Explain how `getColor` behaves when invalid arguments or theme variables are provided.
3. **Usage Examples**: Include a variety of code examples in React with styled-components demonstrating:
* Basic usage with theme variables.
* Use cases for modifying color shades and transparency.
* Examples that utilize the `dark` and `light` modifiers.
* Accessing theme variables through the `variable` prop.
* Usage within styled-components.
4. **Recommended Patterns**: Highlight recommended practices for using `getColor`, such as consistency in accessing theme variables and avoiding hardcoded values.
5. **Anti-Patterns**: Clearly identify patterns that should be avoided (e.g., invalid argument combinations, complex logic within `getColor` calls) and explain why.
6. **Integration with `ThemeProvider`**: Explicitly show how `getColor` utilizes the theme from the `ThemeProvider` and how to access it using the `useTheme` hook from styled-components.
7. **Conclusion**: Summarize the key takeaways and best practices for using `getColor` effectively.
Ensure the documentation is well-structured, easy to navigate, and helpful for developers of all experience levels.
Explanation of Choices and Why These Prompts Should Work:
Role Assignment: Each prompt begins by assigning a role to the LLM (e.g., "expert software engineer", "senior front-end developer", "technical writer"). This helps the LLM understand the context and generate more relevant output.
Specific Instructions: Each prompt provides very specific instructions on what the output should contain, avoiding ambiguity.
Context: They clearly state the technology (React, styled-components, @zendeskgarden/react-theming).
Emphasis on Practicality: Prompts 1 and 2 emphasize practical examples and real-world scenarios so that the LLM does not only generate api documentation but also provides practical applications of the function.
Anti-Pattern Focus: Each prompt includes instructions for highlighting anti-patterns and bad use, which encourages the LLM to focus on best practices in addition to just the usage of the function.
Structured Output: All prompts subtly imply a structured document (Introduction, Usage, etc.) ensuring the LLM does not simply create a list.
Format: The prompts specify markdown as the output format.
Clarity: All prompts emphasize clarity of the generated content.
Double Check:
I have double-checked the prompts to ensure they:
Cover all required aspects of the getColor utility (parameters, return value, theme integration, etc.).
Encourage examples based on the provided code and documentation.
Promote best practices and discourage anti-patterns.
Are clear and concise for the LLM to understand.
These prompts should provide a good starting point for generating high-quality documentation for the getColor utility. Let me know if you have further questions.